題組內容
二、考慮下列關聯式資料庫的三個 table:顧客(Customer)、產品(Product)和交易
(Transaction)。他們的結構(schema)定義如下:Customer(cName, cID, address)、
Product(pName, pID, price)、Transaction(cID, pID, amount)。
(每小題 10 分,共 20 分)
⑴顧客「李大同」要買產品「H 牌手機」一支,請寫出 SQL 指令來更新 table。
詳解 (共 2 筆)
詳解
insert into Transaction (cid, pid,amount)
select cid, pid, price
from customer, product
where customer.cname='李大同' and product.pname='H牌手機’;
詳解
Insert into Transaction
Select cID, (Select pID from Product Where pName = 'H牌手機'),1
From Custom Where cName='李大同'