Sqlite - conditional SELECT?
Something like this:
(SELECT CASE WHEN ((SELECT ID FROM table WHERE language = specified language) IS NULL) THEN default language ELSE specified language END);
It will return your desired language, based on the result of the subquery. Plug that into the WHERE clause of your final query.
Piggybacking on the logic from yko's answer, this separates out the determination of which language to use, then returns all rows for that language:
SELECT * FROM languages WHERE id = '1' AND lang IN (SELECT lang FROM languages WHERE id = '1' AND lang IN ('es', 'en') ORDER BY lang = 'es' LIMIT 1)