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, header() is not working!
Hello, I have this code:


<?php

/**
* @author samoi
* @copyright 200

passing an array of objects after submit
How do I do this? This is what I have tried and it is not working.

<form method="

compile php5 with DOM
Hi,

I can't manage to compile php 5.3.0 from source on Windows to include DOM,
in spite of

need a script for 3 pages
I have a customer who wants me to set up a site with a number of pages with the following requiremen

Extract specific information from a PHP Multidimensional Array
Howdy! I've racked my brain over this for 24 hours now. I think it's time I asked for help. I'm lear

keeps going back to index.html ???????
ok so i started making my site using mostly.html files now i have added a fair chunk of php. My inde

ereg_replace issue
hi there people

i have this code happening with regards to my wamp server. is this something

Printer configuration
Hi All,
Suppose one of the user deleted the printer settings unfortunatly ,then what is the pro

Session login issue
I'm wondering how to fix a problem I'm having with a session-based login system

Say I go to h

Help with ORDER BY
Hello. I would like to order by ascending States, then Cities, then Gyms in the following code, but

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