How can I use the if statement in MYSQL query to return yes if it’s true and no if it’s not?
See the example :
IF(table_name.field_name_value = 1, 'yes','no') AS active
I’m trying something like this but with no success
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From the documentation on
IF()function:So, basically, the syntax is as mentioned above.
EDIT:
You are saying my example is incorrect. Thus, I provide you a proof (which proves the example from the documentation I mentioned above):
I have a table, which has
uidcolumn, containing ID of the user. The table is part of the database on some site (which is not relevant). When I make the following query:I receive the following result:
Which is exactly what I would expect (and what should be expected after reading the documentation). Is it still not working for you?