Hello,
I'm having some troubles with a DISTINCT query. Here is my problem:
I have a table called "test" with collums "a", "b" and "c" and some different values (integers) in them.
Example:
a | b | c
---------
1 | 2 | 3
1 | 2 | 2
1 | 3 | 2
2 | 2 | 2
3 | 2 | 2
3 | 3 | 3
1 | 2 | 3
Notice that many rows have 1 in collum "a". Now I want to get only 1 (ONE) result with collum a set to 1, and one with collum "a" set to 2, and one with collum "a" set to 3 etc. Other collums ("b","c") don't matter as long as I get only one row with collum "a" set to a value.
So from the above table I want these values:
1 2 3
2 2 2
3 2 2
What SQL query to use? I tried
SELECT DISTINCT `a`, `b` , `c`
FROM `test`
WHERE 1
LIMIT 0 , 30
but it returns
1 | 2 | 3
1 | 2 | 2
1 | 3 | 2
2 | 2 | 2
3 | 2 | 2
3 | 3 | 3
Thanks in advance!
I'm having some troubles with a DISTINCT query. Here is my problem:
I have a table called "test" with collums "a", "b" and "c" and some different values (integers) in them.
Example:
a | b | c
---------
1 | 2 | 3
1 | 2 | 2
1 | 3 | 2
2 | 2 | 2
3 | 2 | 2
3 | 3 | 3
1 | 2 | 3
Notice that many rows have 1 in collum "a". Now I want to get only 1 (ONE) result with collum a set to 1, and one with collum "a" set to 2, and one with collum "a" set to 3 etc. Other collums ("b","c") don't matter as long as I get only one row with collum "a" set to a value.
So from the above table I want these values:
1 2 3
2 2 2
3 2 2
What SQL query to use? I tried
SELECT DISTINCT `a`, `b` , `c`
FROM `test`
WHERE 1
LIMIT 0 , 30
but it returns
1 | 2 | 3
1 | 2 | 2
1 | 3 | 2
2 | 2 | 2
3 | 2 | 2
3 | 3 | 3
Thanks in advance!