'I have a issue with the if statement in mysql
I want to execute a if statement which is like this
select IF ( quantity_wanted!=3,(select name from grocerywanted),Null) AS message from grocerywanted;
I want here to check the quantity_wanted column if it contains a value except 3 run the select statement
Solution 1:[1]
Your query is using same table name not as sub query. I think you should use 'name' in replace of '(select name from grocerywanted)'. You will get your desired output.
select IF ( quantity_wanted!=3,name,Null) AS message from grocerywanted;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Deep |
