I am attempting to run an SQL query on the post meta twice to update 2 values, I get the error:
Table 'wp_postmeta' is specified twice, both as a target for 'UPDATE' and as a separate source for data
I have attempted to combine the queries into 1, surely you can run 2 queries to the same table?
<?php
$wpdb->query(
$wpdb->prepare(
"UPDATE {$wpdb->prefix}postmeta
SET meta_value = %s
WHERE meta_key = %s
AND meta_value = %s
IN (
SELECT post_id
FROM {$wpdb->prefix}postmeta
WHERE meta_value = %s
)",
$var1,
'_regular_price',
$var2
)
);
$wpdb->query(
$wpdb->prepare(
"UPDATE {$wpdb->prefix}postmeta
SET meta_value = %s
WHERE meta_key = %s
AND meta_value = %s
IN (
SELECT post_id
FROM {$wpdb->prefix}postmeta
WHERE meta_value = %s
)",
$var3,
'_other_price',
$var4
)
);
join
.