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
Did you know?Explore Trending and Topic pages for more stories like this.

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

problem with sql querry in php script
Hello guys,

What I want to do is I want to read out a csv file and then but te conent ot the

Collecting AOL Search Terms
I am attempting to collect AOL search terms. I know the code is correct (it works for google, bing,

form problem
Hi all, I think this is going to be easy to resolve but for I have been looking at it to long and I

Error with login script
I am getting an error with my login script:

Error:
Code: Warning: Cannot modify header inf

BIG file upload!
Hey guys!

I'm trying to upload a file, it works well with smaller files but with 60mb+, I get

Pre-Fill out a PHP form...??
This is for work actually (geek squad). We have to fill out this online php form at work over and ov

how to read and write into a word document using php...?
hi,
I need,reading and writting into a word document using php.




Thank u inadva

Problems generating word documents on server side for security reasons
I have a problem with word documentation generation when generating a word document (docx) with PHP.

Timer control causing error
I recently decided to add a timer control to an existing page that uses AJAX on my site. As soon as

PDO returns erroneous columns from within pdt
Hi All,

This is a truly weird behavior:
When using a simple pdo fetch, erroneous columns a

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