0

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;
2
  • 3
    And what is the problem with your current query? Commented May 6, 2016 at 11:05
  • Agree with Tim, your case is fine. Commented May 6, 2016 at 11:21

1 Answer 1

1

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

SELECT If(IDParent < 1, 'no', 'yes') AS ColumnName FROM tableName;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.