MYSql Order By Problem???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mischievous
Forum Commoner
Posts: 71
Joined: Sun Apr 19, 2009 8:59 pm

MYSql Order By Problem???

Post by mischievous »

Hey guys I have a this query im trying to run and its not really working...

Code: Select all

SELECT * FROM menu_items WHERE parent = ? ORDER BY ORDER DESC
but it throws an error at me stating there is an error in my syntax... and anyway i try to make it work its not wanting to work correctly? Is it possible to use the WHERE clause with the order by? :banghead:


After posting this topic and placing my SQL statement in the code box I realized that SQL was interpreting my "order" field as another ORDER so, changed the name of the order field and walla it worked. No longer need help on this. Thanks though!

:crazy:
User avatar
akuji36
Forum Contributor
Posts: 190
Joined: Tue Oct 14, 2008 9:53 am
Location: Hartford, Connecticut

Re: MYSql Order By Problem???

Post by akuji36 »

Try this link:

http://www.webproworld.com/database-dis ... -desc.html

In the end the solution was to use:

mysql_query("SELECT distinct town_name FROM real_estate_listings ORDER BY table_id DESC LIMIT 4" , $linkID) or die("connection not made b");

"Distinct" used instead of where command.

ROD

:D
Post Reply