I have a lot of products (nearly 30,000) in woocommerce. The regular price has been set properly, now I want to set the sale price to the regular one with some percentage of discount. I tried with some plugin but I had always a PHP memory error due to the numbers of products. So I'm trying to solve the problem directly in MYSQL.
Here is my SQL code:
UPDATE s
SET s.meta_value = r.meta_value * 0.85,
FROM wp_postmeta s
INNER JOIN wp_postmeta r
ON s.post_id = r.post_id
WHERE s.meta_key = '_sale_price'
AND r.meta_key = '_regular_price'
But there is an error in SQL syntax. Please suggest to me how to correct the code.