[DB-SIG] Multiple Fields in "Order by" Command

James Gardner james at nonzerodigital.co.uk
Wed Nov 24 02:06:54 CET 2004


Hi Casey,

I beleive you wanted to use:

SELECT * from TABLE1 order by FIELD1, FIELD2, FIELD3

using , rather than +

There is a good SQL tutorial at:

http://www.w3schools.com/sql/sql_orderby.asp

Hope that helps,

James
-- 
http://www.pythonweb.org

Casey Bralla wrote:
> I'm trying to sort my database by multiple fields.  I have written a query 
> that says:
> "select * from TABLE1 order by FIELD1 + FIELD2 + FIELD3"
> 
> Unfortunately, while I can sort by any single FIELD, I am unable to create the 
> multi-field sort I want to create.  I've tried parentheses, using the "&" 
> sign, etc.  I figure there's gotta be an easy way to do this... but I'll be 
> darned if I can find it in the docs or on-line.
> 
> Can somebody please point me in the right direction?
> 
> 
> 
> 
> BTW, This list is wonderful!  Thanks to J Kennedy, Jim Tittlser, Randall 
> Smith, Peter Mott, and Chris Cogdon for the help on the "fetchone()" and 
> "fetchmany()" python statements.  With your help, I was able to solve my 
> problem, and I learned a bunch of stuff too.  Thanks, guys!



More information about the DB-SIG mailing list