mysql if function - subquery as a condition

conditional-statements, mysql, subquery

Solution

Enclose the subquery in parentheses:

SELECT IF ((SELECT COUNT(*) FROM mytable), 'yes', 'no');

Problem

I believe the following query is self explanatory: ``` SELECT IF (SELECT COUNT(*) FROM mytable > 0, 'yes', 'no'); ``` Why doesn't it work? And how should I correct it?

Original source