James Tyson wrote:
> select DISTINCT blah, wibble, fnord
> Now, I was under the impression, from what I had read that distinct
> eliminated duplicates from just the column it's used on. However, one of
> my other columns is a unix timestamp (and thus is always different) and
> distinct seems to return all of them.
> Am I wrong, or is MySQL wrong?
If you're doing the above without a WHERE clause, then it should return
all DISTINCT rows of those 3 vars. If, however, you're doing something
select DISTINCT blah, wibble, fnord FROM atale
WHERE tstamp > 19990101000000
Then tstamp becomes part of the DISTINCT. Some other SQL implementations
will give you a syntax error if you try the above. MySQL is more
forgiving, but must stay with the SQL standard of forming the rows bases
on the 4 (not 3) vars. Therefore with MySQL you could INSERT the above
into a temp table and then do another DISTINCT without the WHERE clause
to get the result you're really after.