Hello!
I need to query a table that contains id_equipment, id_customer and id_category columns. Multiplicity: one customer submits many pieces of equipment. One piece of equipment belongs to one category.
I need to write a query to return all id_customer's that have only submitted equipment to category 2. I'm used to oracle with lovely nested selects etc, but my version of mysql, which is 4.0 doesn't allow them, so I'm lost in a world of joins.
What I have so far:
select distinct e1.id_customer
from equipment e1
INNER JOIN equipment e2 ON e1.id_customer = e2.id_customer
and e1.id_category = 2
and e2.id_category <> 2;
This is so wrong!
Help?
I need to query a table that contains id_equipment, id_customer and id_category columns. Multiplicity: one customer submits many pieces of equipment. One piece of equipment belongs to one category.
I need to write a query to return all id_customer's that have only submitted equipment to category 2. I'm used to oracle with lovely nested selects etc, but my version of mysql, which is 4.0 doesn't allow them, so I'm lost in a world of joins.
What I have so far:
select distinct e1.id_customer
from equipment e1
INNER JOIN equipment e2 ON e1.id_customer = e2.id_customer
and e1.id_category = 2
and e2.id_category <> 2;
This is so wrong!
Help?