If is_closed is returned as true from a query, how do I tell the query to set closing_time to closed, instead of displaying what is really in the row… such as 23:00:00 ?
I tried
AND IF(is_closed = 1, 1, 0) closing_time = 'closed'
but that resulted in
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ‘closing_time = ‘closed’ GROUP BY venues.VENUE_NAME’ at line 27
Thanks!
edit closing_time is a date field.
In your field list add a conditional statement:
A tested example may be found here: http://sqlfiddle.com/#!2/108c1/2
In contrast to the IF statement, the CASE statement is ANSI SQL meaning you can run your query on any RDBMS which implements the ANSI standard.