SCM Exists 关联查询

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)

  

posted @ 2020-03-04 20:30  hoge  阅读(121)  评论(0编辑  收藏  举报