sql - Best practice for where clause -
assume have table contract of contracts following fields: contractid, productid, producttype. in table same contractid have 2 possible productid. table populated 2 possible producttype : type1 , type2.
what reason of doing following query in 1 way or in other?
way 1:
select c1.productid, c2.productid contract c1 left join contract c2 on c1.contractid=c2.contractid c1.producttype <>'type2' way 2:
select c1.productid, c2.productid contract c1 left join contract c2 on c1.contractid=c2.contractid c1.contractid not in (select contractid contract producttype = 'type2') thanks smart answers!
way 1 both easier read , easier db engine optimize.
Comments
Post a Comment