34,594
社区成员
发帖
与我相关
我的任务
分享
select t.id,t.C from
(
select id,A as C from table1
union all
select id,B as C from table2
) t
order by t.id
2\
select t1.id,t1.A,t2.B from table1 t1,table2 t2
where t1.id=t2.id
order by t1.id
3\
select t2.id,t2.姓名,t1sheng.名称 as 省,t1shi.名称 as 市
from table2 t2
join table1 t1sheng on t2.省=t1sheng.id
join table1 t1shi on t2.市=t1shi.id
--------------2
select table1.id ,table1.A,table2.B from table1 inner join table2 on table1.id =table2.id
-------------3
select tab2.id,tab2.姓名,tab1.名称 as 省,a.名称 as 市区 from tab2 left join tab1 on tab1.id = tab2.省
left join tab1 a on a.id= tab2.市