SQLumee SQLumee <[email protected]> wrote:
> Hi all, I am trying to retrieve multilingual information from a table but I 
> don't know how to do this query.
> 
> I have a table defined as:
> CREATE TABLE table2 (id integer, language text, title text, primary key (id, 
> language));
> 
> What I want to retrieve are the rows with "spanish" titles or if there is no 
> spanish title available, select the title in the
> first language found.

Try this:

select * from table2 t1
where t1.language = 'spanish' or not exists (
    select 1 from table2 t2
    where t2.id = t1.id and (t2.language = 'spanish' or t2.language < 
t1.language)
);

Igor Tandetnik

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to