SQL Server 2005.
I have 2 lists:
-
(‘a’, ‘b’, ‘c’, ‘d’)
-
(‘d’, ‘e’, ‘f’, ‘g’)
I need to make a WHERE clause with these 2 inside a dynamic SQL string, something like:
select *
from tbl
where ... afewconditionshere ...
AND anyitemfrom[('a', 'b', 'c', 'd')] is inside [('d', 'e', 'f', 'g')]
it looks kinda weird, but I get this data from a 3rd party, cannot make too big changes
the lists would always have < 20 items inside
UPDATE
a,b,c,d,e,f,g are like security things not related to the table in any way, the idea is that if you have this anyitemfrom[(‘a’, ‘b’, ‘c’, ‘d’)] is inside [(‘d’, ‘e’, ‘f’, ‘g’)] then you are able to view the records returned, otherwise no records should be returned
yes this condition should basically return true or false
i figured it out
i used something like :
for both lists
then I was able to join them, and use the join’s recordcount