Hello
I have a very simple task, but I cannot find any solution. I have two tables, 'articles' and 'categories'
My article table look like this:
id | cat_id | title | content
1 1 Blah Content 1
2 1 Blah2 Content 2
3 2 Blah3 Content 3
My categories table look like this:
id | title
1 Category 1
2 Category 2
You see I have 2 articles that have the same cat_id. I do not want with duplicate cat_id field. I cannot use DISTINCT, because I will get all articles, because I want all fields out.
so if i use DISTINCT like this:
SELECT DISTINCT a.id, a.cat_id, a.title, a.content FROM articles AS a
I will get everything out, but I want output like this
id | cat_id | title | content
2 1 Blah2 Content 2
3 2 Blah3 Content 3
Can someone help me please !!!