• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
新能源汽车行业用户产品设计
新能源汽车行业、面向C端用户的产品设计
博客园    首页    新随笔       管理     

左联接小结

左联接小结
select u.staff_NO, s.STAFF_NAME, S.*, u.*

  
from M_USER_INFO U

  
left join MS_V_STAFF_INFO S on u.staff_NO = s.staff_NO

   
and s.dept_code = '4'

 
where u.app_id = 'MS'

 

 

select u.staff_NO, s.STAFF_NAME, S.*, u.*

  
from M_USER_INFO U

  
left join (select * from MS_V_STAFF_INFO where dept_code = '4') S on u.staff_NO =

                                                                       s.staff_NO

 
where u.app_id = 'MS'

上述两个SQL文,逻辑意义一样。但是下面SQL文,意义就不一样了,结果上区别很大,有兴趣的可以在Tg4server-MS中试验一下

关键在[and s.dept_code = '4']这句话

select u.staff_NO, s.STAFF_NAME, S.*, u.*

  
from M_USER_INFO U

  
left join MS_V_STAFF_INFO S on u.staff_NO = s.staff_NO

where u.app_id = 'MS'

   
and s.dept_code = '4'

 
posted @ 2006-09-26 15:21  阿一(杨正祎)  阅读(333)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3