删除时加入
我正在使用mysql:
- btableA有tableB_id列
- tableB有some_interestring_column_on_TableB
我想要(下面的伪sql):
delete from tableA
where the associated row in tableB (via tableB_id) has
some_interestring_column_on_TableB = 'interestingValue'
请帮我将伪sql翻译成真正的sql。
I'm working with mysql:
- btableA has tableB_id column
- tableB has some_interestring_column_on_TableB
I want (pseudo sql below):
delete from tableA
where the associated row in tableB (via tableB_id) has
some_interestring_column_on_TableB = 'interestingValue'
Please help me to translate the pseudo sql into real sql.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
Try this:
MySQL 支持 DELETE 语句中的 JOIN,以及从一个表中的多个表中删除单个语句。以下内容只会从 TABLEA 中删除:
如果您想从两个表中删除,请使用:
也就是说,这种支持在其他数据库中非常罕见 - 您必须使用
IN
或大多数情况下存在
。MySQL supports JOINs in the DELETE statement, as well as deleting from multiple tables in a single statement. The following will only delete from TABLEA:
If you wanted to delete from both tables, use:
That said, this support is very uncommon in other databases -- you'd have to use
IN
orEXISTS
in most cases.我不知道 mysql 语法,但我在想类似的东西(来自 mssql):
I don't know mysql syntax but I'm thinking something like (from mssql):