Using an IF Statement in a MySQL SELECT query
The IF/THEN/ELSE construct you are using is only valid in stored procedures and functions. Your query will need to be restructured because you can’t use the IF() function to control the flow of the WHERE clause like this. The IF() function that can be used in queries is primarily meant to be used in the … Read more