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

Grids not displaying decimals, and behaving differently on different PCs?
Hello,

I coded a relatively simple MII application that allows data from a form to be add

Using unserialize()
Hi there.

I have some data in my database that is serialized.

e.g.

a:2:{i:0

Cron Job and Output
I have php codes running under a cron job.
But everytime i output (echo) , it comes out as comple

Displaying data from MySql a different way
Hi all,
I'm pretty new to php and MySql and have hit a problem.

I am able to display data

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

newbie question about multiple queries
hi everyone,
I'm sorry to ask such a basic question, but I'm young and trying to learn php on my

Email to a friend script problems
I have this send-to-a-friend script with 2 issues:


1) When you open the form popup on a p

Custom array sort? asc then desc
Any ideas how I could sort this array? I've been trying for a while. Maybe with usort, but I have no

big pagination problem in php
<?php

$connect = mysql_connect("localhost", "root", "")

Not loading image
When this function gets loaded it doesn't load the image just trying to figure out why.

Code:

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