I have a table with languages.
I would like to make a query that gets rows with specified language, but if it won’t return any data – with default language.
Is this possible to do in one query?
UPDATE:
My table: Language
Fields:
id – (primary key, unique),
lang – (text, not unique),
content – (text, not unique).
and my current query is:
SELECT * FROM Languages WHERE (id='1') AND (lang = 'es')
As I mentioned before if above query won’t return anything I would like to get results form default language:
SELECT * FROM Languages WHERE (id='1') AND (lang = 'en')
‘en’ is default language in this example.
Something like this:
It will return your desired language, based on the result of the subquery. Plug that into the WHERE clause of your final query.