码迷,mamicode.com
首页 > 数据库 > 详细

sql left join on

时间:2016-07-11 22:31:32      阅读:390      评论:0      收藏:0      [点我收藏+]

标签:

select sysuser.userid,
       sysuser.groupid,
       sysuser.sysid,
       nvl( userjd.mc,nvl(useryy.mc,usergys.mc)) sysmc
  from sysuser
  left join userjd on sysuser.sysid = userjd.id
  left join useryy on sysuser.sysid = useryy.id
  left join usergys on sysuser.sysid = usergys.id

 

 select SYSUSER.id,
         SYSUSER.userid,
         SYSUSER.username,
         SYSUSER.groupid,
         SYSUSER.sysid,
         decode(SYSUSER.Groupid,
                ‘1‘,
                (select mc from userjd where id = sysuser.sysid),
                ‘2‘,
                (select mc from userjd where id = sysuser.sysid),
                ‘3‘,
                (select mc from useryy where id = sysuser.sysid),
                ‘4‘,
                (select mc from usergys where id = sysuser.sysid)
                ) sysmc
       
          from SYSUSER

 

sql left join on

标签:

原文地址:http://www.cnblogs.com/justuntil/p/5661847.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!