Home > database > A federated query problem, if the first left JOIN does not conform to the record of use under a left
A federated query problem, if the first left JOIN does not conform to the record of use under a left
Time:03-13
Such as
Select * from HouseType HT If the following leftjon query record LEFT the JOIN (SELECT img, img_t img_s, itemID, imgType from ClientHouseImg where imgType='TypeImg') ST on (HT) HouseTypeID=st. itemID) Otherwise, LEFT the JOIN (SELECT img, img_t img_s, itemID, imgType from ClientHouseImg where imgType='ybj') SH on (SH) itemID=HouseID)
Meaning, the two left the JOIN but can only choose one, or in front of this without a record, with a second left JOIN somehow, please tall person to give directions, thank you very much
CodePudding user response:
Write a if decide first
CodePudding user response:
Select * The from (select *, dense_rank () over (partition by st. itemID order by rn) as rn_new from HouseType HT LEFT the JOIN (SELECT img, img_t img_s, itemID, imgType, Case the when imgType='TypeImg' then one else 2 end as an rn from ClientHouseImg where imgType in (' TypeImg ', 'ybj)) ST on (HT) HouseTypeID=st. itemID)) as A Where A.r n_new=1