首页 > 代码库 > 个人比较喜欢用的链表查询
个人比较喜欢用的链表查询
select distinct b.MaterialID,a.id,a.InNo,a.Title,a.FromType,a.FromBillID,d.orderNo ,a.Executor,h.EmployeeName as ExecutorName,a.Processor,e.EmployeeName as ProcessorName ,a.EnterDate,a.projectID,a.totalProduct ,case a.billStatus when ‘0‘ then ‘制单‘ when ‘1‘ then ‘执行‘ when ‘2‘ then‘结单‘ end as b illStatus ,a.DepId,f.CustName,b.ID as detailID,b.ProductNo,b.ProductName,b.Specification,b.size ,b.unit,b.StorageID,c.StorageName,b.StorageDID,sd.ProductCount,c.StorageDName ,b.ProductCount,b.procedureNO,b.arts,b.RunCard,b.RuncardStatus from officedba.OutSourceInfo a left join officedba.OutSourceDetail b on a.InNo=b.InNo left join officedba.StorageDetailInfo c on c.ID=b.StorageDID and c.StorageNo=b.StorageID left join officedba.PurchaseOrder d on a.FromBillID=d.OrderNO left join officedba.EmployeeInfo e on e.ID=a.Processor left join officedba.ProviderInfo f on f.ID=a.DepId left join officedba.EmployeeInfo h on h.ID=a.Executor left join officedba.ProductInfo i on b.ProductNo=i.ProdNo left join MaterialDetailInfo j on j.MD03=i.ID left join officedba.CodeUnitType cu on cu.ID=b.Unit left join officedba.TechnicsArchives ta on ta.TechNo=b.arts left join officedba.RunCardDetail sd on sd.runcard=b.runcard and sd.ProcedureID=b.procedureNO where a.InNo=‘CKDBH2017040060‘
之前写过一个关联查询和子查询效率对比的博客,流露出自己对关联查询的青睐,如果逻辑足够清晰,关联查询是一个不错的选择。(上面是自己刚写的一个关联查询的sql语句,拿出来晒晒,总觉得有一两米长)
本文出自 “11929767” 博客,请务必保留此出处http://11939767.blog.51cto.com/11929767/1917997
个人比较喜欢用的链表查询
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。