码迷,mamicode.com
首页 > 其他好文 > 详细

SCM Exists 关联查询

时间:2020-03-04 21:20:32      阅读:65      评论:0      收藏:0      [点我收藏+]

标签:rom   exists   and   sha   class   date   pre   config   ike   

Exists  效率应该比in 高一些

SELECT  DictItemID,DictSortCode,DictSortId,DictItemName,DictItemSName
from scm_dict  where   EXISTS( SELECT DictSortCode FROM scm_dict_config where  DictSortCode= scm_dict.DictSortCode)
and del_flag=‘0‘
order by DictSortCode 


SELECT id
        ,DictItemID AS dictItemID
        ,DictSortCode AS dictSortCode
        ,DictSortId AS dictSortId
        ,DictItemName  AS dictItemName
        ,DictItemSName AS dictItemSName
        from scm_dict where  EXISTS( SELECT DictSortCode FROM scm_dict_config where  DictSortCode= scm_dict.DictSortCode)
        and del_flag =‘0‘
        order by DictSortCode

SELECT dictSortCode from scm_dict where dictSortCode=‘sys_bargainor_type‘

SELECT * from scm_dict where create_by !=‘excel‘ or create_by is NULL
and DictItemSName like ‘%集团%‘

update scm_dict d,scm_dict_config c  set d.DictSortCode=c.DictSortCode where d.DictItemSName=c.DictSortName
and  d.DictSortCode is null and  (c.DictSortCode like ‘%_type%‘ or LENGTH(c.DictSortCode)>12)

SELECT d.id,c.id,  d.DictSortCode,d.DictItemSName,c.DictSortCode from scm_dict d INNER join  scm_dict_config c on d.DictItemSName=c.DictSortName
where d.DictSortCode is null and  (c.DictSortCode like ‘%_type%‘ or LENGTH(c.DictSortCode)>12)

  

SCM Exists 关联查询

标签:rom   exists   and   sha   class   date   pre   config   ike   

原文地址:https://www.cnblogs.com/hoge66/p/12411965.html

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