I am using code:
create table table3 as
select a.*,b.*
from
table1 a
left join
table2 b
on a.id=b.id
where a.date>=b.date
and a.age<b.age
however,table1 has 20000 rows and table3 has only 5000 rows.It seems the where clause filter all the null values.
When I am using code:
create table table4 as
select a.*,b.*
from
table1 a
left join
table2 b
on (a.id=b.id
and a.date>=b.date
and a.age<b.age)
I would get an error "both left and right aliases encountered in join",because I used inequality in join conditions.
So,how could I get more than 20000 rows include null values by using left join?Should I join multiple times or could use another more effective way?