I'd like to create a query like that looks up a value from another table if the value of a particular field is not 0. Like this?
SELECT id, name, type, site_id
IF (site_id > 0)
THEN (SELECT id FROM setups WHERE setups.id = image.site_id) as site
ELSE "" as site
FROM image
ORDER BY image.id
Can someone help me with the syntax for doing the SELECT in the middle, only if the value of site_id is not 0 and based on the value of site_id. If the site_id = 0, I need return an empty string.
Thanks!