I have a database with questions and answers that get translated into all languages that site is used by. But when a question is not translated yet I want to show that question in english language. So a gettext-like behavior.
My current SQL query for this looks like this:
SELECT * FROM questions_view WHERE `language` = "de" AND `#parent` IS NULL
UNION
SELECT * FROM questions_view WHERE `language` = "en" AND `#parent` IS NULL
AND id NOT IN (SELECT id
FROM questions_view
WHERE `language` = "de")
But I feel like this is not the optimal way of doing this. Any tips?