无法运行查询给出 mySQL 错误 #1093 - 您无法在 FROM 子句中指定目标表“成员”进行更新 [重复]
Posted
技术标签:
【中文标题】无法运行查询给出 mySQL 错误 #1093 - 您无法在 FROM 子句中指定目标表“成员”进行更新 [重复]【英文标题】:Unable to run query gives mySQL error #1093 - You can't specify target table 'members' for update in FROM clause [duplicate] 【发布时间】:2014-01-09 14:48:25 【问题描述】:我一直在处理一个查询,它获取表记录的子集并更新它们,但不知何故我无法让它工作它给我错误#1093 - You can't specify target table 'members' for update in FROM clause
这里是查询:
UPDATE members set is_deleted = 1
WHERE EXISTS
(SELECT m1.member_id FROM members as m1
WHERE m1.member_id NOT IN
(select member_id
from membership_payment_profiles
WHERE (next_date_to_charge > "2012-12-31 00:00:00"
or next_date_to_charge is null)
order by next_date_to_charge DESC
)
and m1.joined_on < "2012-12-31 00:00:00"
)
【问题讨论】:
【参考方案1】:试试这个查询
update members m1 set m1.is_deleted=1 where m1.member_id not in (select distinct member_id
from membership_payment_profiles
WHERE (next_date_to_charge > "2012-12-31 00:00:00"
or next_date_to_charge is null) order by next_date_to_charge DESC) and m1.joined_on < "2012-12-31 00:00:00";
【讨论】:
以上是关于无法运行查询给出 mySQL 错误 #1093 - 您无法在 FROM 子句中指定目标表“成员”进行更新 [重复]的主要内容,如果未能解决你的问题,请参考以下文章
MySQL错误1093 - 无法在FROM子句中指定更新的目标表
错误 1093:MySQL 无法在 FROM 子句中指定更新的目标表
Mysql 错误:1093 - 无法在 FROM 子句中指定要更新的目标表