Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Matching one list to another

We all know that in order to match a field from A to a field in B, where B
is a list (1, 2, 3) we have to take the field in B, and dump that into a
temporary table, then match the field in A against that built table. But
what if we had a field in A that was also a list?

Basically I have a single record in A, and it has a list of capabilities.
Now B has multiple records that list requirements. So what I am trying to
do is match the requirements against the capabilities so that A.x, can find
all the records in B that it is capable of servicing... obviously B can't
have more requirements.

What I figured I would do is take the requirements of A, and generate a query
that looks like this:
(pseudo code)
A.x = (1,2,3,4)

loop and build sql string with A.x
-> select B.id B if (count of B requirements)=4 and 1 in (B requirement)
and 2 in (B requirements) and 3 in (B requirements) and 4 in (B requirements)
end loop

create an insert statement for a temp table
-> insert into #mymatches(ID)
( built sql string )

Done.. use table results before finishing query
Drop #mymatches

Does this seem like a likely way to do this? The poor server is gonna pounded
if there are a lot of matches and a lot of people looking for matches at
the same time.
[1379 byte] By [Adrian] at [2007-11-9 21:11:31]