MySQL Forums
Forum List  »  Newbie

Re: A problem with IFstatement.
Posted by: Andrew Gilfrin
Date: July 26, 2005 06:44AM

You can actually use if statements inside of an SQL statement.

mysql> select if(emp_id=1,'X','Y') as test, emp_id from emps;
+------+--------+
| test | emp_id |
+------+--------+
| X | 1 |
| Y | 2 |
| Y | 3 |
+------+--------+
3 rows in set (0.06 sec)

Not sure if this fits in with what you want to do which may have to be done using an external program.

Andrew Gilfrin
------------------
http://gilfster.blogspot.com
My MySQL related Blog

http://www.mysqldevelopment.com
MySQL Stored Procedure,Trigger, View.... (Just about most things these days) Information

Options: ReplyQuote


Subject
Written By
Posted
Re: A problem with IFstatement.
July 26, 2005 06:44AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.