I've got a query that I build up based on user choices; part of the
query, I want to have it return a short list of IDs based on said choices.
So for example let's say that the user chooses "color = 'red'" and "day
of week = 'tuesday'".
I need to pull out a list of the IDs where both values match.
One trick is, data is stored in two different tables, tied to varying
other IDs. Now, doing single queries to get these matches is cake, and
then looping over those lists and figuring out what IDs are in both
recordsets is cake. But I'm unsure as to the SQL syntax to do it within
a single query.
I'm basically looking for the opposite, or semi-opposite of UNION.
I'm wondering if I need to go this route:
select ID from table where ID IN (
select ID from table2 where (datamatch)
and ID IN (
select ID from table3 where (other data match)
)
)
i.e. just do nesting all the way through. I'm going to give this a shot
whilst those of you who are so inclined, mull this one over. :D
--Scott
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Macromedia ColdFusion MX7
Upgrade to MX7 & experience time-saving features, more productivity.
http://www.adobe.com/products/coldfusion?sdid=RVJW
Archive: http://www.houseoffusion.com/groups/SQL/message.cfm/messageid:2777
Subscription: http://www.houseoffusion.com/groups/SQL/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.6