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)
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)