I have used the CASE statement for ordering many times.  It's very useful...

SELECT
myDATA,
CASE
WHEN data2 = SomeValue
THEN 0
ELSE
WHEN data2 = SomeOtherValue
THEN 1
ELSE
2
END
AS mySort
from MyTable Where myConstraints.


God Bless

Paul C. McNeil
Developer in Java, MS-SQL, MySQL, and web technologies.














GOD BLESS AMERICA!
To God Be The Glory!

-----Original Message-----
From: Rafi Sheikh [mailto:[EMAIL PROTECTED]
Sent: Friday, June 18, 2004 12:21 PM
To: '[EMAIL PROTECTED]'
Subject: MySQL SQL Case Stetement


Hi list.  Can someone give me a working example of a SQL CASE statement(in
SELECT)?  I have examples for stored procedures, but none for use within the
DML side of SQL.

I am trying to in my SELECT (used in PHP) create a variable/col for example:
 status='high' where value in a other col is withinin certain range.

I am sure that I do not have the order of the syntax or complete code.  I am
using MySQL 4.0.17, and a newbie.

Any simple example will help.

Please note I am not requesting for use within a procedure or trigger, etc,
just a simple DML side SELECT.

TIA

RS


This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity to
which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified that
any dissemination, distribution or copying of this e-mail is prohibited. If
you have received this e-mail in error, please notify the sender by replying
to this message and delete this e-mail immediately.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to