You are here: Re: mysql select group « PHP SQL « IT news, forums, messages
Re: mysql select group

Posted by Sutha Balasubramaniam on 07/17/06 14:45

Thanks for your response. With:

mysql_query("SELECT a,b,c,d,e FROM my_table WHERE d!='0' && a='1' GROUP
BY b
ORDER BY c DESC LIMIT 21");

I see the query now, however it does not do the 'ORDER BY c DESC'
part! Basically, it doesn't sort in DESC order! Any ideas?

Thanks again for helps.

Rik wrote:
> Sutha Balasubramaniam wrote:
> > Can someone please tell me what's wrong with this query?
> >
> > mysql_query("SELECT a,b,c,d,e FROM my_table WHERE d!='0' && a='1'
> > GROUP BY b ORDER BY c DESC LIMIT 21");
> >
> > This returns nothing! Appreciate any helps.
>
> echo mysql_error();
>
> It's probably the GROUP BY clause.
> If there are several possibilities for c,d & e where b is the same, the
> server doesn't know what to show.
>
> Test:
> mysql_query("SELECT a,b FROM my_table WHERE a='1' GROUP BY b LIMIT 21");
> and:
> mysql_query("SELECT a,b,c,d,e FROM my_table WHERE d!='0' && a='1' GROUP BY b
> ORDER BY c DESC LIMIT 21");
> To see if the rest of the query is OK.
>
> Grtz,
> --
> Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация