Vadivel Murugan
Vadivel Murugan

Reputation: 53

If else condition in mysql query

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

Answers (1)

Mippy
Mippy

Reputation: 364

Try this;) Take a look of mysql-if-function.

SELECT If(IDParent < 1, 'no', 'yes') AS ColumnName FROM tableName;

Upvotes: 1

Related Questions