Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
svibuk
Yak Posting Veteran
62 Posts |
Posted - 2013-08-14 : 01:46:36
|
i have a subquery in which i need to use case statement for using joinhave the following MID IN (SELECT HId FROM TBLDETAILS D INNER JOIN TBLMAS M on M.ID= D.DID WHERE M.MID<>0 )need to add a case statement as below but it gives errorMID IN (SELECT HId FROM TBLDETAILS D INNER JOIN TBLMAS M on case when type='M' THEN M.ID= D.DID ELSE M.MID=D.MID END WHERE M.MID<>0) |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-08-14 : 03:01:39
|
try this...MID IN (SELECT HId FROM TBLDETAILS D INNER JOIN TBLMAS M on (M.ID = case when type='M' THEN D.DID END) OR (M.MID = CASE WHEN type !='M' THEN D.MID END) WHERE M.MID<>0) --Chandu |
|
|
svibuk
Yak Posting Veteran
62 Posts |
Posted - 2013-08-14 : 03:31:31
|
Thanks very muchsolved my issue |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-08-14 : 03:45:31
|
quote: Originally posted by svibuk Thanks very muchsolved my issue
welcome--Chandu |
|
|
ShivaKrishna
Starting Member
20 Posts |
Posted - 2013-08-28 : 07:41:24
|
MID IN (SELECT HIdFROM TBLDETAILS DINNER JOIN TBLMAS M on( type='M' and M.ID= D.DID)INNER JOIN TBLMAS M2 on M2.MID=D.MIDWHERE M.MID<>0 AND M2.MID<>0 ) |
|
|
|
|
|