On Sun, November 16, 2008 12:14, Joel wrote:
> take a look at this
> http://www.devx.com/dbzone/Article/17403/1954
>
>
> On Sat, Nov 15, 2008 at 10:56 PM, ray <[EMAIL PROTECTED]> wrote:
>
>>
>> Hi, All
>>
>> I have two tables named product and category:
>> Product table:
>> prod_id prod_name ...
>> Category table:
>> cat_id cat_name ...
>>
>> Product and category have a relationship of Multiple-to-Multiple. So
>> there is another association table named prod_in_cat:
>> pc_id pc_prod_id pc_cat_id
>>
>> I want to select a particular set of products along with one of its
>> categories in a single sql query, is that possible to implement it?
>>
>>
>> Thanks
>>
>> >
>>
>
> >
>
nice simple version of this would be something like

select p.*
from prod_in_cat pic
join product p on pic.prod_id = p.prod_id
join category c on pic.cat_id = c.prod_id
where c.cat_name = "whatever" -- assuming you want to select based on this

This would get you the list of all products that were in  a particular
category
if you only want a subset of the products then you could add

and c.prod_name in (a, bunch, of, stuff)

to your where clause




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Oracle PL/SQL" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Oracle-PLSQL?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to