> Sorry about the non-descriptive subject, but I'm tired and really couldn't
> think of a way to describe my question in one line <g>.
>
> I have a database table of product information and a database table of
> product category information.  Each product may exist in more than one
> category, so I created a "mappings" table that simply contains
> ItemID-CategoryID pairs.  This is all well and good.
>
> I am trying to write a product details query that includes a
> comma delimited
> list of the CategoryIDs that the product belongs to.  Currently I run two
> queries: one for the data from the product table and another for the
> CategoryIDs from the mappings table.  Then I create a list of the Category
> IDs and manually add the list to the query of other product data.
>
> Is there a way to get SQL to do this for me in one query?  As far
> as I know
> subqueries are only useful when they return a single value, which won't
> quite work here.  Any ideas?

Right, I'm not gonna address the whole thing (no time at the moment), but a
quick word about sub-queries

They should be used in 2 ways - one to return a single result;
select * from myTable where myValue=(select myValue from myOtherTable
where...)

Or to return multiple values
select * from myTable where myValue in (select myValue from myOtherTable
where...)

The second is a lot more useful for what you're looking for

Hope this gives you a push in the right direction

If I get more time later, I'll expand, but quite busy at the moment...
sorry.

Philip Arnold
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************


------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to