php - Error while updating table value -
this question has answer here:
- how 3 table join in update query? 4 answers
i have 2 tables: table1
, wp_posts
. first 1 custom table, second 1 wordpress one.
i want change post types in wp_posts
match criteria post_title
same headline
in table1
, type_id
key equals 41.
i tried selecting kind of posts
select * wp_posts left join table1 on table1.headline = wp_posts.post_title table1.type_id = 41
and correct posts (i'm doing in phpmyadmin).
so tried with
update wp_posts set wp_posts.post_type = 'jobs' wp_posts join table1 on table1.headline = wp_posts.post_title table1.type_id = 41
and error
#1064 - have error in sql syntax; check manual corresponds mariadb server version right syntax use near 'from wp_posts join table1 on table1.headline = wp_posts.post_title w' @ line 1
the table (roughly)
table1
headline | type_id -------------------- random | 41 random 2 | 41
wp_posts
post_title | post_type -------------------- random | post random 2 | post
and need change post
jobs
post_title | post_type -------------------- random | jobs random 2 | jobs
the names (post_title
, headline
) unique, there won't duplicates etc.
what's wrong alter
sql statement?
try this:
update wp_posts join table1 on table1.headline = wp_posts.post_title set wp_posts.post_type = 'jobs' table1.type_id = 41;
Comments
Post a Comment