留言表(message):
id int ID
評論表(comment):
id ID
user_id 用戶ID
mess_id 留言ID
回復表(reply):
id ID
com_id 評論ID
user_id 用戶ID
關系:
留言表與評論表 1:m
評論表與回復表 m:n
問: 已知留言表ID,用SQL陳述句如何實作洗掉留言表內容,同時能夠洗掉評論表和回復表對應的內容?
懇請各位路過的大佬幫幫忙




uj5u.com熱心網友回復:
DELETE message, `comment`, reply
FROM message
LEFT JOIN `comment` ON `comment`.mess_id = message.id
LEFT JOIN reply ON reply.com_id = `comment`.id
WHERE message.id = 666
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/19829.html
標籤:MySQL
下一篇:并發洗掉時,資料庫死鎖問題求解!
