Update using LEFT JOIN
MySQL UPDATE query using LEFT JOIN
<?php
UPDATE tickets LEFT JOIN tickets tickets2 ON (tickets2.id = (tickets.id -1))
SET tickets.timestamp = tickets2.timestamp
WHERE tickets.purchase_type LIKE "permit%" AND tickets.statistics_date >= "2021-03-15" AND tickets.timestamp IS NULL;
#LIMIT can't be used here, use this instead (not tested myself):
UPDATE wp_postmeta t JOIN
(
SELECT p.meta_id, m.newmap
FROM wp_postmeta p JOIN wp_map m
ON p.meta_value = m.oldmap
ORDER BY p.meta_id
LIMIT 100
) s
ON t.meta_id = s.meta_id
SET t.meta_value = s.newmap;
?>
Knowledge keywords: