我正在尝试运行此sql查询并不断收到此错误:
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 靠近'INNER JOIN wp_posts ON wp_postmeta.post_id = wp_posts.ID WHERE 第3行(第4行)的wp_posts.post_typ'
我的SQL查询是这样的:
UPDATE wp_postmeta
SET meta_value = "1316"
INNER JOIN wp_posts ON wp_postmeta.post_id = wp_posts.ID
WHERE wp_posts.post_type="imagen_dia" AND wp_postmeta.meta_key="ae_post_template"
请帮忙吗?
答案 0 :(得分:2)
在mysql中,JOIN应该在set
之前UPDATE wp_postmeta
INNER JOIN wp_posts ON wp_postmeta.post_id = wp_posts.ID
SET meta_value = "1316"
WHERE wp_posts.post_type="imagen_dia" AND wp_postmeta.meta_key="ae_post_template"
答案 1 :(得分:1)
联接更新的语法是特定于供应商的。所以这样做没有连接,使更新语句简单,可读和安全: - )
UPDATE wp_postmeta
SET meta_value = '1316'
WHERE meta_key = 'ae_post_template'
AND post_id IN (SELECT id FROM wp_posts WHERE post_type = 'imagen_dia');
此语句是标准SQL,应该适用于每个RDBMS。
答案 2 :(得分:0)
您错过了FROM
字词:
UPDATE wp_postmeta
SET meta_value = "1316"
FROM wp_postmeta
INNER JOIN wp_posts ON wp_postmeta.post_id = wp_posts.ID
WHERE wp_posts.post_type="imagen_dia" AND wp_postmeta.meta_key="ae_post_template"