[GENERAL] ORDER BY problems

2000-02-18 Thread David Shrewsbury

I cannot seem to get ORDER BY to work properly when I
want to sort using two different columns. I have code
similar to the following:

SELECT tracking_num, username
FROM reports
WHERE customer='$customer'
ORDER BY tracking_num, username

This will sort by tracking_num (int4, primary key), but
NOT by the username (varchar, not null). The confusing thing
is if I use:

ORDER BY username, tracking_num

it works, but it sorts by username first and then the
tracking number which is the reverse of what I want to do.
Why doesn't the first bit of code work as I expect?

-David





Re: [GENERAL] ORDER BY problems

2000-02-18 Thread omid omoomi

hi,
As far as I understand,tracking_num is primary key and uniqe! So when you 
sort the date by a uniqe field their would be no place for other fields to 
be sort on! May be you are going to sort the data some other way.
so I think your query is doing well.
Omid Omoomi

From: David Shrewsbury [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [GENERAL] ORDER BY problems
Date: Fri, 18 Feb 2000 20:52:06 +

I cannot seem to get ORDER BY to work properly when I
want to sort using two different columns. I have code
similar to the following:

SELECT tracking_num, username
FROM reports
WHERE customer='$customer'
ORDER BY tracking_num, username

This will sort by tracking_num (int4, primary key), but
NOT by the username (varchar, not null). The confusing thing
is if I use:

 ORDER BY username, tracking_num

it works, but it sorts by username first and then the
tracking number which is the reverse of what I want to do.
Why doesn't the first bit of code work as I expect?

-David



__
Get Your Private, Free Email at http://www.hotmail.com