List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:June 12 1999 7:07pm
Subject:DISTINCT question
View as plain text  
>>>>> "Alexander" == Alexander I Barkov <bar@stripped>
> writes:

Alexander> Hi!
Alexander> I can run this query in MySQL:

Alexander> SELECT DISTINCT field1
Alexander> FROM sometable
Alexander> GROUP BY field2;

Yes, but does it really return what you want?
(The above isn't a query that is allowed in ANSI SQL)

Alexander> Is there any way to do something like this:

Alexander> SELECT DISTINCT field1
Alexander> FROM sometable
Alexander> GROUP BY some_expression_on_field2;

Alexander> How to implement this without using a temporarily
Alexander> table?

Alexander> Thanks for help!

Hi!

Why would you like to do the above?
(I assume the above isn't your real Query, as it doesn't make sense;
In this case post the real query so that we can help you!)

The normal way would be to do:

SELECT field1,some_expression_on_field2 as tmp FROM sometable
GROUP BY field1,tmp;

and then do some last manipulation in the client.

Regards,
Monty
Thread
DISTINCT questionAlexander I. Barkov12 Jun
  • Re: DISTINCT questionTani Hosokawa12 Jun
  • DISTINCT questionMichael Widenius12 Jun