July 26, 2004 at 11:51 pm
I have a reference table like this,
1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 |
I have another table on which I have to check for a particular column for all the cell values existing in the reference table.
Somthing like this.
Select * from order where ord_id in (1,2,3,4,5,6,7,8)
The above query should be dynamic.
Any thoughts.
Cheers,
Ganesh
July 27, 2004 at 12:31 am
This should work, though it's a bit ugly
SELECT * FROM order WHERE ord_id IN
(
SELECT Col_A FROM Ref UNION
SELECT Col_B FROM Ref UNION
SELECT Col_C FROM Ref UNION
SELECT Col_D FROM Ref
)
HTH
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 28, 2004 at 3:11 am
Thanks a lot. It worked fine.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply