mysql - Getting SQL syntax error in INSERT query in wordpress database -
I'm using insert query down to enter a custom name for all WordPress post, but SQL syntax error is
wp_postmeta (post_id, meta_key, meta_value) select ID inserted as post_id, meta_key as' CustomField '' MyValue not where ID wp_posts as meta_value (from wp_postmeta Where meta_key = post_id select 'CustomField') and 'post_type =' post ';
You touch a comma for a single quote to isolate the column and wrap the string .
(post_id, meta_key, meta_value) Select putting wp_postmeta ID post_id, 'CustomField' as as meta_key, 'MyValue' meta_value as no where id wp_posts (wp_postmeta Where meta_key = select 'post_id' from 'CustomField') and post_type = 'post'; not An alternative to using joining two tables, insert wp_postmeta (post_id, meta_key , meta_value) join a.ID selection post_id, 'CustomField' as as meta_key, 'MyValue as meta_value from wp_posts' a left a.ID = b.post_id and b.meta_key = 'CustomField' wp_postmeta B Where a.post_type = 'Post' and 'B.post_id IS FAL'
Comments
Post a Comment