Garayed.com  

Go Back   Garayed.com > mySQL
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-22-2006, 11:46 PM
Bill Karwin
 
Posts: n/a
Default Re: Point me to some references for Sorting

"Marty Meyers" <martym@execpc.com> wrote in message
news:1221g89ld0dtoab@corp.supernews.com...
> if (ColA=0)
> { // use Col B}
>
> elseif(ColA > 0 && colA < ColB)
> { // use Col A
> }
> else
> { //use ColB}


SELECT ...
ORDER BY CASE
WHEN ColA = 0 THEN ColB
WHEN ColA > 0 AND ColA < ColB THEN ColA
ELSE ColB
END

It's based on the fact that the arguments to ORDER BY are expressions, not
simply column names. You can use things like CASE and IF() to make
interesting, complex expressions. Read more about these functions here:
http://dev.mysql.com/doc/refman/5.0/...functions.html

> The MsSQL manual doesn't seem to cover this, nor does the two beginner
> books I have. A pointer to a reference where I can learn about advanced
> "Order by" would be great


It's not much, but here's an article I found through Google:
http://www.sqlteam.com/item.asp?ItemID=2209
It's written for Microsoft SQL Server users, but it mostly applies to MySQL
as well.

Regards,
Bill K.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:14 PM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.