mysql删除加入? [英] mysql delete on join?

查看:106
本文介绍了mysql删除加入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用

select * from sent_txts s 
LEFT JOIN received_txts r ON s.msg_link_id = r.id 
WHERE r.action_id = 6;

顶部选择匹配的行,

如何编写查询以删除双方匹配的行?

How can I write a query to delete the matching rows on both sides?

类似

delete sent_txts s 
LEFT JOIN received_txts r ON s.msg_link_id = r.id 
WHERE r.action_id = 6;

推荐答案

免责声明:目前,我无权访问要测试的mysql数据库,但我认为您可以使用:

Disclaimer: I do not have access to a mysql database to test at the moment, but I think you can use:

delete s, r from send_txts s left join received_txts r on s.msg_link_id = r.id where r.action_id = 6;

有关更多信息,请参见mysql的删除文档.更好的方法可能是将外键约束从receive_txts发送到发送,然后级联删除.

See mysql's delete documentation for more information. A better method might be to put a foreign key constraint from received_txts to sent, and cascade the delete.

这篇关于mysql删除加入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆