onedumbcoder Posted May 27, 2009 Share Posted May 27, 2009 Is it possible to have an if statement inside a query? something like this: SELECT IF type = 0 THEN 'car' AS t ELSEIF type = 1 THEN 'bike' AS t FROM machine WHERE ownser='mike' Quote Link to comment Share on other sites More sharing options...
corbin Posted May 27, 2009 Share Posted May 27, 2009 http://dev.mysql.com/doc/refman/5.0/en/case-statement.html Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 27, 2009 Share Posted May 27, 2009 SELECT IF(type=0,'car','bike') AS t FROM machine WHERE ownser='mike' That should work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.