The issue has to do with relating a PRODUCT table and ATTRIBUTE table so
that one product is related to multiple attributes. In the shopping cart, I
want to show multiple select menus. After a user selects all of them, only
the parts related to those attributes will be displayed.

Example:

PRODUCT (product_id, etc.)
Part #100 - has attributes 1, 2
Part #200 - has attribute 1

ATTRIBUTE (product_id, attribute_id)
Part_ID, Attribute - GREEN (1)
Part_ID, Attribute - Aluminum (2)

Want to select all products from PRODUCT that are both Green and Aluminum.
In Oracle, I can do this using the INTERSECT command.

select product_id from PRODUCT P, ATTRIBUTE A where P.product_id =
A.product_id and Attribute = 1
INTERSECT
select product_id from PRODUCT P, ATTRIBUTE A where P.product_id =
A.product_id and Attribute = 2

A temporary table may work, but I do not like this as a solution as I would
have to maintain an extra table with non-relevant data (need to constantly
insert and delete data). I tried playing with outer joins, but I don't know
how to get it to do this.

thanks,
-tom

-----Original Message-----
From: Roger Baklund [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 23, 2002 10:43 AM
To: MySQL List
Cc: [EMAIL PROTECTED]
Subject: RE: alternative to intersect in mySQL


* Thomas Moore

> > I know that intersect does not work yet with mySQL. I am selecting data
> from
> > two tables. Results of one select
> > would be 1, 2, 3, 4 . Results of other select 1, 2.
>
> > Want to print 1, 2.
>
> > Are there any nice workarounds using PHP or SQL?

[temporary table]

> If it is in a multi-user environment, this is undesirable. Any other
> thoughts?

Maybe you could give us some more details about the problem?

"Result of one select"...? Is this a complex joined select which you can not
expand to include the second select? Is it different hosts/databases? Why
can you not use a join?

select a.id from a,b where a.id = b.id

--
Roger


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to