0

Hello Friends,

I have a table which says stores 4 values
id,publisher name,bookname,time

I am firing query like

SELECT * from table where time>='sometime' group by `publisher name` order by time DESC

What I want is to select results in DESC order of time with unique publisher name.
When I fire this query, it gives me unique publisher name but time is reverse ordered, I mean it execute group by first and hence order by time doesnt take any effect.

Can any one siggest the right queyr which will give me most recent(time wise) unique listings.

Hemanshu

2
Contributors
2
Replies
6
Views
3 Years
Discussion Span
Last Post by Lsmjudoka
0

GROUP BY isn't intended for use like this, it's supposed to be used with a MySQL function like COUNT() or MIN() to return information about a resultset from multiple rows. If you want everything sorted by publisher name first, then by time, you simply need to run the query ordered by two columns:

SELECT * FROM `table` WHERE `time` >= 'sometime' ORDER BY `publisher_name` DESC, `time` DESC
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.