您不能在 FROM 子句中为更新指定目标表“wp_mail_queue" [英] You can't specify target table 'wp_mail_queue' for update in FROM clause

查看:34
本文介绍了您不能在 FROM 子句中为更新指定目标表“wp_mail_queue"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误:

您不能在 FROM 中指定更新目标表 'wp_mail_queue'条款

You can't specify target table 'wp_mail_queue' for update in FROM clause

因为这个查询:

DELETE FROM wp_mail_queue 
WHERE message_id = (SELECT message_id FROM wp_mail_queue ORDER BY id LIMIT 0, 1)
ORDER BY wp_mail_queue.id 
LIMIT 100

我想它是子查询的结果.用 SELECT * 替换 DELETE,它会准确返回我想要删除的条目.我需要的是一种重写它的方法,这样我就不需要在该子查询中查询 wp_mail_queue,或者完全避免使用子查询.

And I suppose it results from the subquery. Replace DELETE with SELECT * and it returns exactly the entries that I want to delete. What I need is a way to rewrite this so that I won't need to query wp_mail_queue in that subquery, or avoid the subquery entirely.

我首先想到的是变量,如果我能以某种方式将子查询分配给一个然后使用它?

My thoughts went first to variables, if I could somehow assign the subquery to one and then use that?

推荐答案

尝试:

DELETE FROM wp_mail_queue 
WHERE message_id = (SELECT * FROM (SELECT message_id FROM wp_mail_queue ORDER BY id LIMIT 0, 1) queue_table)
ORDER BY wp_mail_queue.id 
LIMIT 100

这篇关于您不能在 FROM 子句中为更新指定目标表“wp_mail_queue"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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