I'm trying to run this sql query and keeps getting this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNER JOIN wp_posts ON wp_postmeta.post_id = wp_posts.ID WHERE wp_posts.post_typ' at line 3 (Line 4)
My sql query is this:
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"
Any help please?
In mysql the JOIN should be before the 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"
The syntax for joined updates is vendor-specific. So do this without a join to have the update statement simple, readable and safe :-)
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');
This statement is standard SQL and should work in about every RDBMS.
You are missing the FROM
word:
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"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.