Reputation: 53
How can I use if and else condition in mysql query. Here is my query.
SELECT CASE WHEN IDParent < 1 THEN 'no' ELSE 'yes' END AS ColumnName FROM tableName;
Upvotes: 0
Views: 71
Reputation: 364
Try this;) Take a look of mysql-if-function.
SELECT If(IDParent < 1, 'no', 'yes') AS ColumnName FROM tableName;
Upvotes: 1