[resolved] Ordering SQL selects by multiple cols

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ibanez270dx
Forum Commoner
Posts: 74
Joined: Thu Jul 27, 2006 12:06 pm
Location: Everywhere, California

[resolved] Ordering SQL selects by multiple cols

Post by ibanez270dx »

Hi,
I was wondering if there was a way to select the data out of my database and order it by multiple fields. For example:

Code: Select all

SELECT * FROM $table_name WHERE id=$idnum ORDER BY year AND month AND day
So... am I right or is this not the way to do it?

Thanks,
- Jeff
Last edited by ibanez270dx on Mon Jul 31, 2006 10:23 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

swap ANDs for commas.

SQL != PHP. :arrow: Databases.
Post Reply