The CASE function is documented in the manual
<http://dev.mysql.com/doc/mysql/en/Control_flow_functions.html>.
SELECT CASE
WHEN other_col < 100 THEN 'low'
WHEN other_col BETWEEN 100 AND 1000 THEN 'medium'
WHEN other_col > 1000 THEN 'high'
END AS col
FROM your_table;
Michael
Rafi Sheikh wrote:
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
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]