MYSQL if statement question...
Posted
by Dennis_M
on Stack Overflow
See other posts from Stack Overflow
or by Dennis_M
Published on 2009-12-14T01:17:30Z
Indexed on
2010/05/09
5:08 UTC
Read the original article
Hit count: 237
mysql
|if-statement
Is there any way to get the if statement to evaluate a query? SELECT if(5>0,'EQ_Type','*') FROM EQUIPMENT; Resulting in: +-----------------------+ | IF(5>0,'EQ_Type','*') | +-----------------------+ | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | | EQ_Type | +-----------------------+ 9 rows in set (0.00 sec) I would like the above statement to be equivalent to the following: SELECT 'EQ_Type' FROM EQUIPMENT; And produce: +--------------+ | EQ_Type | +--------------+ | ENGINE | | ENGINE | | ENGINE | | TRAILER | | TRAILER | | TRAILER | | WATER TENDER | | WATER TENDER | | WATER TENDER | +--------------+ Thanks for any help
© Stack Overflow or respective owner