Page 1 of 1

[MYSQL] Select Unique Where Value Is Largest

Posted: Fri Mar 02, 2012 8:53 am
by lenton
I have this table:
Image

I want to select all fields where time is the highest value and conversation is unique so it returns these two rows:
Image

My current SQL query doesn't give me the correct results that I'm looking for:
[text]SELECT * FROM `table` GROUP BY `conversation` ORDER BY `time` DESC[/text]
Image

I need GROUP BY to select the unique row with the highest value in `time`.
How can I achieve this?

Re: [MYSQL] Select Unique Where Value Is Largest

Posted: Fri Mar 02, 2012 3:33 pm
by Christopher
Try:[text]SELECT * FROM `table` GROUP BY `time`,`conversation` ORDER BY `time` DESC[/text]

Re: [MYSQL] Select Unique Where Value Is Largest

Posted: Sat Mar 03, 2012 7:56 am
by lenton
Christopher wrote:Try:[text]SELECT * FROM `table` GROUP BY `time`,`conversation` ORDER BY `time` DESC[/text]
It returns all rows:
Image

:(