PDA

View Full Version : ORDER BY 2 Items ASC.


Morgoth
08-10-2003, 08:17 AM
Hello,

I need to sort two fields that come out of the database, the first field is to tell me if I should run the rest of the code or not, and the second field is the information I want to display.

The first field is a boolean, and since I am checking to see if any of the fields equal false, I will sort the field. If the first field sorted in ASCENDING ORDER equals 1 Then I don't do the script, else if the first field sorted in ASCENDING ORDER equals 0 Then I will run the script.

Inside the script I need to get the information out of it in alphabetical order.

I can only do one sql statement saying "..ORDER BY ___ ASC"

How can I make the information in the script line up in alphabetical order?

Thanks for any input you can give me that puts me on my way to solving my problem.

raf
08-10-2003, 11:18 AM
Morgoth,

I don't quite understand it.
If the first field sorted in ASCENDING ORDER equals 1 Then I don't do the script, else if the first field sorted in ASCENDING ORDER equals 0 Then I will run the script.
What do you mean by this? a sorted field that equals 1 ? If you only need records where the first field is 0, then use a condition on it like 'WHERE firstfield = 0' or so?


I can only do one sql statement saying "..ORDER BY ___ ASC"
:confused: You know tou can sort on multiple columns, rihgt?
Like 'ORDER BY field1 ASC, field2 ASC, field3 DESC'

Morgoth
08-10-2003, 10:44 PM
Like 'ORDER BY field1 ASC, field2 ASC, field3 DESC'


I didn't think that was how to did it, but it works raf, thank you.

I thought it was:

"...ORDER BY id ASC AND ORDER BY field2 ASC"

But I was wrong.

Thanks again raf!

raf
08-11-2003, 08:21 AM
You're welcome. Glad you got it working :thumbsup: