> select coalesce(RT1.PID, RT2.PID) as PID, RT1.V1, RT2.V2 ... I find function ifnull() more readable in such cases. ;-)
Pavel On Fri, Sep 18, 2009 at 7:21 PM, Igor Tandetnik <itandet...@mvps.org> wrote: > Stef Mientki <s.mien...@ru.nl> wrote: >> create table RT1 ( PID integer, V1 text ); >> insert into RT1 values ( '684', 'aap' ); >> insert into RT1 values ( '685', 'other empty' ); >> create table RT2 ( PID integer, V2 text ); >> insert into RT2 values ( '684', 'beer' ); >> insert into RT2 values ( '686', 'other empty' ); >> select RT1.*, RT2.* >> from RT1 >> left join RT2 on RT1.PID = RT2.PID >> union >> select RT1.*, RT2.* >> from RT2 >> left join RT1 on RT1.PID = RT2.PID >> where RT1.PID IS NULL; >> >> Now I want to combine the columns PID, so the result would look like >> >> PID V1 V2 >> 686 from RT2 >> 684 from RT1 from RT2 >> 685 from RT1 > > select coalesce(RT1.PID, RT2.PID) as PID, RT1.V1, RT2.V2 ... > > Modifying the second select clause is left as an exercise for the > reader. > > Igor Tandetnik > > > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users