mysql delete兩種關聯刪除方式


基本格式:

 DELETE t1 FROM t1,t2 WHERE  t1.id= t2.id 或 DELETE FROM t1 USING t1,t2 WHERE  t1.id= t2.id 
示例應用:

DELETE coupon FROM coupon,member WHERE coupon.mem_no=member.reg_no AND coupon.`status`=0 AND coupon.`batch_no`='yaoqingpengyou001' AND member.`mobile` IN (
182xxxx9886
)

//關聯用戶表,根據手機號碼查詢該會員號對應的券(批次號為yaoqingpengyou001且未使用status=0)刪除。

DELETE FROM coupon USING coupon,member WHERE coupon.mem_no=member.reg_no AND coupon.`status`=0 AND coupon.`batch_no`='yaoqingpengyou001' AND member.`mobile` IN (
182xxxx9886


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM