ITeye博客

oracle多表连接查询

shaq34 · 2009-08-01 11:41 · Markdown


select b.u_code,b.u_id,b.u_fullname,m.value from ( SYS_USER_BASEPROFILE b inner join SYS_ORG_UMEMBER u
on b.u_code=u.u_code and u.org_code in (220966001776)) left join SYS_USER_EXTPF_MOBILE m
on b.u_code=m.u_code

这里例子的意思根据条件取得a表和b表中的全部交集,以此为准查找c表中与之相关数据。 其中join type可以根据需要随意变化,语法如下。


select a.*,b.*,c.* from(tableA a inner join tableB b on a.col1=b.col2)
left join tableC c on b.col1=c.col2

inner join 内连接,根据条件取两表交集。作用与select * from tableA a,tableB b where a.col1=b.col2相同

left join 取前面表中所有记录,根据条件在后一张表中取相关记录,没有记录为null,right join作用类似,方向变化。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。