problem with GROUP BY and ORDER BY


Posted on 16th Feb 2014 07:03 pm by admin

i usually use this query to display the last 10 entries from a sql table:

Code: $query = "SELECT search_time, search_keywords FROM phpbb_popsearch ORDER BY search_time DESC limit 35";
as you can see it will order the results by "search_time" so the latest entries are listed first

normally the result would be something like this:
Quotenew entry
duplicate
another entry
bla bla
348237
543543
duplicate


but now i just want to include a "GROUP BY" in this sql request
Code: $query = "SELECT search_time, search_keywords FROM phpbb_popsearch ORDER BY search_time DESC limit 35";
but with the GROUP BY my sql query isn't ordered correctly anymore.

the result would be something like this:
QuoteQuotenew entry
another entry
bla bla
348237
543543
duplicate


notice the "duplicate" entry was grouped together, but it's not in the second first position anymore ???

i was expecting a result like this:
Quotenew entry
duplicate
another entry
bla bla
348237
543543

Since entry called "duplicate" is the second last added entry....

i hope you understand what i mean

No comments posted yet

Your Answer:

Login to answer
175 Like 43 Dislike
Previous forums Next forums
Other forums

Undefined index: username HELP NEWBIE
I am trying a simple login/logout for my website. It works well with checking if the username exists

textfield unchanged
hi,
i want my form to know whether its textbox is unchange or not.

if($textbox == 'unchang

in php, link returns to the line
When I add a link in a php page, the link word returns to the line (as a
would do)

Examp

how do I show what a user have selected from a checkbox?
From my code below, how would i show which check boxes have been checked and which radio buttons sel

If a record matches an existing record do nothing
So I don't know if I should put this here or in mysql, but what my script is for is for people to ad

Checkbox info wont include in Mailto
Hey, im new to php.
Basically I have made a form to request which type of job(s) are needed, whic

File upload issues
Hi Guys,

Can anyone see any issues with this code:
Code: $setImage= 'productimages/' . dat

Reading Most Recent CSV File in Directory
I thought I had wrapped this project up, but found out that the program I use to FTP a csv file to m

get the country of visitor and display content based on that
Hello all,

I have seen that Google analytics can tell you where a visitor is coming from and

Backflush
I am looking for a report in SAP that would give me a list of all parts that are populated with a ba

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash