How return a value with mysql query depending on condition?
Solution 1:
Do something like this
SELECT MAX(result)
FROM (
SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END AS result
FROM cl_convenios_do_medico
WHERE med_id = 8
AND conv_id = 9
UNION
SELECT CASE WHEN COUNT(*) = 0 THEN 1 ELSE 0 END
FROM cl_convenios_do_medico
) c
DEMO