Is there any way to get the if statement to evaluate a query? SELECT if(5>0,\'EQ_Type\',\'*\') FROM EQUIPMENT; Resulting in: +-----------------------+ | IF(5>0,\'EQ_Type\',
I recommend using ANSI notation - CASE statements in this case - rather than MySQL specific syntax:
SELECT CASE WHEN 5 > 0 THEN t.eq_type ELSE '*' END
FROM EQUIPMENT t
Reason being, if you changed databases - this statement wouldn't need to be changed to work on Oracle, Postgres, SQL Server, etc.
Just remove the single quotes.
SELECT if(5>0,EQ_Type,'*') FROM EQUIPMENT;