Update query for wp_posts and wp_postmeta

The post_id column in the wp_postmeta table is a reference to the ID column in the wp_posts table.

I’d suggest using the native update_post_meta() function in WordPress to update the meta data.

E.g. (Post ID is 123 in this example, and we’re updating the price to 100.00):

update_post_meta(123, '_price', '100.00');

Here is the SQL equivalent:

UPDATE wp_postmeta
SET meta_value = 100.00
WHERE meta_key like '_price' AND post_id = 123;