SQL
[mysql] join, union
Kee.
2020. 6. 27. 13:29
There are two sample tables.
select * from info;
select * from info1;
join
select * from info
join info1
on info.ID = info1.no;
the join is to make the same condition both tables based on ID
select * from info
left join info1
on info.ID = info1.no;
The left join is the second table will be into the first table.
union
select cc.code
from info1 as cc
union all
select dd.code
from info as dd;
'union all' includes all values. 'union' ignores the same values.
the number of columns should be same.
select ID, Ecode , day_time
from info
union all
select *
from info1;