gpt4 book ai didi

mysql - 错误 #1093 - 您无法在 FROM 子句中指定用于更新的目标表 'wp_posts'

转载 作者:行者123 更新时间:2023-11-29 20:50:00 27 4
gpt4 key购买 nike

我正在尝试使用 MySql Quariy 更改帖子并不断收到 1093 Err我已经尝试了所有有关使用子查询的技巧,但没有成功

也许有人可以帮助我

UPDATE wp_posts SET post_content  = CONCAT(post_content , 'testext_bla_bla')
WHERE wp_posts.id in (select wp_posts.ID
from wp_posts
LEFT JOIN wp_term_relationships on wp_posts.ID = wp_term_relationships.object_id
LEFT JOIN wp_term_taxonomy ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id
LEFT JOIN wp_terms ON wp_terms.term_id = wp_term_relationships.term_taxonomy_id
WHERE wp_posts.post_excerpt like '%LO1185LH%' and wp_term_taxonomy.term_taxonomy_id = 27)

并不断收到“#1093 - 您无法在 FROM 子句中指定要更新的目标表“wp_posts””

谢谢阿萨夫

最佳答案

为更新的表使用别名;)

UPDATE wp_posts t1 SET t1.post_content = CONCAT(t1.post_content, 'testext_bla_bla')
WHERE t1.id IN (
SELECT wp_posts.ID
FROM wp_posts
LEFT JOIN wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id
LEFT JOIN wp_term_taxonomy ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id
LEFT JOIN wp_terms ON wp_terms.term_id = wp_term_relationships.term_taxonomy_id
WHERE wp_posts.post_excerpt LIKE '%LO1185LH%' AND wp_term_taxonomy.term_taxonomy_id = 27)

或者您可以使用LEFT JOIN来执行此操作;)

UPDATE wp_posts t1
LEFT JOIN wp_term_relationships ON t1.ID = wp_term_relationships.object_id
LEFT JOIN wp_term_taxonomy ON wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id
LEFT JOIN wp_terms ON wp_terms.term_id = wp_term_relationships.term_taxonomy_id
SET t1.post_content = CONCAT(t1.post_content, 'testext_bla_bla')
WHERE t1.post_excerpt LIKE '%LO1185LH%' AND wp_term_taxonomy.term_taxonomy_id = 27

关于mysql - 错误 #1093 - 您无法在 FROM 子句中指定用于更新的目标表 'wp_posts',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38141306/

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