P粉1649427912023-08-28 10:18:24
DELETE a.*, b.* FROM messages a LEFT JOIN usersmessages b ON b.messageid = a.messageid WHERE a.messageid = 1
翻譯:從表格messages中刪除,其中messageid = 1,如果表格uersmessages有messageid =表messages的messageid,則刪除該行用戶訊息表。
P粉5956057592023-08-28 09:11:20
不能用分號分隔它們嗎?
Delete from messages where messageid = '1'; Delete from usersmessages where messageid = '1'
或
只需使用INNER JOIN
,如下所示
DELETE messages , usersmessages FROM messages INNER JOIN usersmessages WHERE messages.messageid= usersmessages.messageid and messages.messageid = '1'