个人比较喜欢用的链表查询
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语句,拿出来晒晒,总觉得有一两米长)
成都创新互联公司长期为上千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为爱民企业提供专业的成都做网站、成都网站制作,爱民网站改版等技术服务。拥有十年丰富建站经验和众多成功案例,为您定制开发。
当前题目:个人比较喜欢用的链表查询
路径分享:http://pwwzsj.com/article/pdcpdc.html