Need to find all words with their Italian translation, if Italian doesn\'t exist, then need with Spanish (default language). I can`t use more than one query, and where e
I'd join the words
table on the translations
table twice, once for each language:
SELECT w.id,
w.name,
COALESCE(it.translation, es.translation) AS translation,
COALESCE(it.language, es.language) AS language
FROM words w
LEFT JOIN translation it ON w.id = it.word_id AND it.language = 'it'
LEFT JOIN translation es ON w.id = es.word_id AND es.language = 'es'