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

help with multi-update
Now sure how to ask this really....
10g database if that matters.

I have a customer

mysql_real_escape_string
Let me preface this that I am very much a PHP noob, but I have some SQL training (not necessarily My

Php script to read msword file
hi,

I need to read a msword file and i want to print the contents in that word file.

i

Typing math
I've added support for typesetting math using LaTeX on the forums.

Example:
Code: [Select]

mysql select query problem
how can i select multiple fields from multiple table in one query like

i have table name t1 a

How to use Substr
I want to check for the word CATEGORY: inside a string which can be CATEGORY: ITEM
and remove the

PHP IMAGE UPLOAD SCRIPT
Hi for the last week i have been looking for scripts that will upload a photo to a certain folder wh

Mysql error message
help me find out what this error message means:

"Duplicate entry '0' for key 'PRIMARY'&q

help, header() is not working!
Hello, I have this code:


<?php

/**
* @author samoi
* @copyright 200

help with contest script
I would like to code a contest script to my site but i don't know how. Could someone just give me pu

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