mysql delete兩種關聯刪除方式

基本格式:mobile

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

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

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 ) 
相關文章
相關標籤/搜索