I think the shorter way is:
SELECT * FROM table WHERE id IN ('21') AND COALESCE(content_id IN ('0', ''), 1)
content_id IN ('0', '') can take these values:
- True if conent_id is either
'0' or '' - Null if
conent_id IS Null - False otherwise.
If it is Null, with COALESCE I return 1, which is equivalent to True.
source share