They should return the same values, but possibly in a different order.

  SELECT foo, bar, baz FROM table GROUP BY foo, bar, baz;

returns the values of foo, bar, and baz, once for each unique combination,
ordered by foo, bar, baz.  That is, GROUP BY does a free ORDER BY.

  SELECT DISTINCT foo, bar, baz FROM table;

returns the values of foo, bar, and baz from every row in no particular
order (as they are found) with duplicates removed.  If you have a
multi-column index on (foo, bar, baz), in that order, however, mysql may
satisfy this query by looking at the index rather than at the table.  In
that case, you should again get the rows sorted by foo, bar, baz, simply
because the index is in that order.

Are you getting different results?

Michael

Scott Haneda wrote:

Are these 2 statements the same?

tSql1 = select distinct foo, bar, baz from table
tSql2 = select foo, bar, baz from table group by foo, bar, baz

Why would I get different results?


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to