#眉標=MySQL、insert、update #副標=MySQL管理技巧(3) #大標=運用MySQL子查詢更新資料 #作者=文/圖 葉建榮 ======<反灰>=========== select customerid,companyname from customers where customerid in (select customerid from orders group by customerid having count(*)>5 ); ================= ======<反灰>=========== insert into insertcustomers(customerid,contactname,city) select employeeid, firstname, city from insertemployees; ================= ======<反灰>=========== delete deleteorders.* from deleteorder_details, deleteorders where deleteorder_details.orderid=deleteorders.orderid and deleteorder_details.unitprice<20; ================= ======<反灰>=========== update updateproducts, updateorder_details set updateorder_details.quantity=updateorder_details.quantity+2, updateproducts.unitprice=updateproducts.unitprice*0.2 where updateproducts.productid=updateorder_details.productid and updateorder_details.unitprice>120; ================= ======<反灰>=========== select updateorder_details.quantity,updateproducts.unitprice from updateproducts, updateorder_details where (updateproducts.productid=updateorder_details.productid and updateorder_details.unitprice>120); =================