I am not sure how cases work with mysql, can anyone explain what’s wrong with this query?
CASE WHEN SELECT COUNT(*) from websites where website_id = 171 and master = 2 > 0
SELECT timestamp from websites where website_id = 171 and master = 2
ELSE SELECT NOW() as timestamp
Check out MySQL Control Flow Functions
CASE…WHEN needs to have a
THENkeyword to work.You probably want:
If there are only two possibilities, though, you’re better with IF:
Or, you could use IFNULL and skip the count(*)