删除引用多个表在 MYSQL 上不起作用

发布于 2024-12-01 22:10:00 字数 360 浏览 1 评论 0原文

我正在尝试使用其他表的联接从表中删除。

我的sql如下:

DELETE FROM `threadsread` 
USING `mybb_threads` t
WHERE
threadsread.tid=threads.tid and threadsread.uid in (2111, 2564, 2326, 2510) 
and mybb_threads.fid=30

但我收到以下错误:

1109 - 多重删除中的未知表“mybb_threadsread”

这些都不是视图,都是真实的表。我可以使用类似的 SQL 运行选择,没有任何问题。

I'm trying to delete from a table, using join from other tables.

My sql is the following:

DELETE FROM `threadsread` 
USING `mybb_threads` t
WHERE
threadsread.tid=threads.tid and threadsread.uid in (2111, 2564, 2326, 2510) 
and mybb_threads.fid=30

But I get the following error:

1109 - Unknown table 'mybb_threadsread' in MULTI DELETE

None of those are views, all are real tables. And I could run a select using a similar SQL, without any problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沫离伤花 2024-12-08 22:10:00

请看下面来自 Mysql.com 的内容

对于第一个多表语法,仅匹配来自
FROM 子句之前列出的表将被删除。对于第二个
多表语法,仅匹配列出的表中的行
FROM 子句(USING 子句之前)被删除。效果是
您可以同时从多个表中删除行并拥有
仅用于搜索的附加表:

从 t1 内连接 t2 内连接 t3 中删除 t1、t2,其中 t1.id=t2.id
且 t2.id=t3.id;或者:

使用 t1 INNER JOIN t2 INNER JOIN t3 WHERE 从 t1、t2 中删除
t1.id=t2.id 且 t2.id=t3.id;这些语句使用所有三个表
搜索要删除的行时,但仅删除匹配的行
表 t1 和 t2。

Please take a look at the below from Mysql.com

For the first multiple-table syntax, only matching rows from the
tables listed before the FROM clause are deleted. For the second
multiple-table syntax, only matching rows from the tables listed in
the FROM clause (before the USING clause) are deleted. The effect is
that you can delete rows from many tables at the same time and have
additional tables that are used only for searching:

DELETE t1, t2 FROM t1 INNER JOIN t2 INNER JOIN t3 WHERE t1.id=t2.id
AND t2.id=t3.id; Or:

DELETE FROM t1, t2 USING t1 INNER JOIN t2 INNER JOIN t3 WHERE
t1.id=t2.id AND t2.id=t3.id; These statements use all three tables
when searching for rows to delete, but delete matching rows only from
tables t1 and t2.

梦在深巷 2024-12-08 22:10:00

我设法让它与以下 sql 一起工作:

delete  FROM threadsread
USING  threadsread 
 inner join threads
WHERE
threadsread.tid=threads.tid and threadsread.uid in (2111, 2564, 2326, 2510) 
and threads.fid=30

感谢 CA 的 M. 的帮助

I managed to get it working with the following sql:

delete  FROM threadsread
USING  threadsread 
 inner join threads
WHERE
threadsread.tid=threads.tid and threadsread.uid in (2111, 2564, 2326, 2510) 
and threads.fid=30

Thanks for the help M. of CA

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文