gpt4 book ai didi

mysql - 数据库查询失败示例;你能帮我解决问题吗?

转载 作者:行者123 更新时间:2023-11-29 16:18:54 26 4
gpt4 key购买 nike

我正在尝试更新名为“dogs_postmeta”的 Wordpress 数据库表。下面是我的查询,它非常适合显示所有适当的数据。

select meta_value as field_i_want_to_change, i.url as data
from dogs_postmeta
inner join (select a.post_id, CONCAT('https://mydomain/wp-content/uploads/', b.meta_value) as url
from
dogs_postmeta a, dogs_postmeta b
where
a.meta_key = '_thumbnail_id' and
b.post_id = a.meta_value and
b.meta_key = '_wp_attached_file'
) i
on i.post_id = dogs_postmeta.post_id
where
dogs_postmeta.meta_key = "_seopress_pro_rich_snippets_article_img"
limit 100;

我想使用上述“数据”属性更新现有字段 - meta_value。我已经这样做了几个小时但没有成功。

这是我尝试过的。

update dogs_postmeta
set dogs_postmeta.meta_value = i.url
from (select a.post_id, CONCAT('https://mydomain/wp-content/uploads/', b.meta_value) as url
from
dogs_postmeta a, dogs_postmeta b
where
a.meta_key = '_thumbnail_id' and
b.post_id = a.meta_value and
b.meta_key = '_wp_attached_file'
) i
inner join dogs_postmeta on dogs_postmeta.post_id = i.post_id
where
dogs_postmeta.meta_key = "_seopress_pro_rich_snippets_article_img";

我收到此错误消息 -

Error in query (1064): Syntax error near 'from (select a.post_id, CONCAT('https://mydomain/wp-content/uploads/', b.meta_va' at line 3

...但我确信这不是问题所在。

谁能帮我解决这个问题吗?

最佳答案

update dogs_postmeta as d
inner join (select a.post_id, b.meta_value as url
from
dogs_postmeta a, dogs_postmeta b
where
a.meta_key = '_thumbnail_id' and
b.post_id = a.meta_value and
b.meta_key = '_wp_attached_file'
) as i on d.post_id = i.post_id
set d.meta_value = CONCAT('https://mydomain/wp-content/uploads/', i.url)
where
d.meta_key = "_seopress_pro_rich_snippets_article_img";

关于mysql - 数据库查询失败示例;你能帮我解决问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54624433/

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