gpt4 book ai didi

加入时删除mysql?

转载 作者:可可西里 更新时间:2023-11-01 06:44:19 26 4
gpt4 key购买 nike

我可以用

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

顶部选择匹配的行,

如何编写查询来删除两边的匹配行?

有点像

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

最佳答案

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

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 的 delete文档以获取更多信息。更好的方法可能是将外键约束从 received_txts 放到 sent 中,然后级联删除。

关于加入时删除mysql?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3402403/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com