tags:

views:

78

answers:

3

I have the following table structure.

 A | B | C

I wish to pull column A and B where all the results of A and B are distinct. I wish to ignor column C. My unerstading of the distinct keyword that it looks at the whole row not jst the columns you return. Any ideas how I could do this?

+2  A: 

Your understanding is wrong. DISTINCT does not look at the whole row. Did you try something like this?

SELECT DISTINCT(A, B) FROM t WHERE ...
+3  A: 

Not so. DISTINCT looks at whatever columns you specify. So for you, SELECT DISTINCT A, B FROM table.

I'd prefer the GROUP BY though: SELECT A, B FROM table GROUP BY A, B

Randolph Potter
A: 

SELECT DISTINCT doesn't look at the whole row in the database, it just looks at the requested columns. So you can just do SELECT DISTINCT a, b FROM mytable and it will completely ignore column c.

Seb Woolford