hello,
I'm trying to join 2 tables,
so I guess I need to perform a full outer join.
On wikipedia, I found this solution for sqlite3:
http://en.wikipedia.org/wiki/Join_%28SQL%29
select *
from RT0
left join RT1 on RT1.PID = RT0.PID
union
select RT0.*, RT1.*
from RT1
left
> Now the strange thing is that this query returns the correct number of rows,
> but all the columns from the employee-table are empty.
There's no "employee-table" in your query.
> If I change "UNION" to "UNION ALL" the join works as expected.
> Is there an explanation for this behavior ?
As we
thanks Pavel,
and sorry for mixing the wikipedia example with the real situation.
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'
Stef Mientki 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 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 wrote:
> Stef Mientki wrote:
>> create table RT1 ( PID integer, V1 text );
>> insert into RT1 values ( '684', 'aap' );
Pavel Ivanov wrote:
>> select coalesce(RT1.PID, RT2.PID) as PID, RT1.V1, RT2.V2 ...
>>
>
> I find function ifnull() more readable in such cases. ;-)
>
>
thanks guys,
both (of course ;-) works perfectly.
I have to study the functions in SQLite some more !!
cheers,
Stef
___
6 matches
Mail list logo