Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help needed!Basic INTERSECT application

Status
Not open for further replies.

DJPace

Computer
Oct 26, 2002
1
Hello!

I've set up a new mini database related to a mini business (for which the tables definition have been appended to this message). Now, I need to know every "IdPro" that is ordered for each client for whom agent "a03" places an order. By the way, "commande" is the same as "order" and "Montant" is the same as "amount". I tried the following querry, but it doesn't work:

SELECT IdPro FROM commande
WHERE IdAge='a03' intersect all
SELECT distinct IdCli FROM commande WHERE IdAge='a03';

So, what's wrong?

Thanks in advance!

P. Délisle


N.B.:

Here's "commande" table definition:

CREATE TABLE commande (
IdCom VARCHAR2(10) NOT NULL,
IdPro VARCHAR2(10),
IdCli VARCHAR2(10),
IdAge VARCHAR2(10),
DateCom DATE,
Qte NUMBER NOT NULL CHECK (Qte > 0),
Montant NUMBER NOT NULL CHECK (Montant > 0),
PRIMARY KEY(IdCom),
FOREIGN KEY(IdPro) REFERENCES produit(IdPro) ON DELETE CASCADE,
FOREIGN KEY(IdCli) REFERENCES client(IdCli) ON DELETE CASCADE,
FOREIGN KEY(IdAge) REFERENCES agent(IdAge) ON DELETE CASCADE
);


IdCom: the ID of the order
IdPro: the ID of the product ordered
IdCli: the ID of the client
IdAge: the ID of the agent
DateCom: the date when the ordered has been done
Qte: the quantity of the product ordered
Montant: the amount of the order (for that product)


 
Replies continue below

Recommended for you

I think the first part of your query looks okay and should be enough to get your results. Try entering just

SELECT * FROM commande WHERE IdAge='a03'

If that does not work, try replacing the equal sign after IdAge with the LIKE statement. I've seen some SQL drivers that will only accept = when comparing two columns or a column to a specific numeric-only value.

Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor