0

I trying to copy data from one product feed plugin to another. First thing I have to do is create a empty meta_key '_woosea_brand' but only to this posts where another meta_key 'woocommerce_ceneo_Producent' exist. Later i will copy the meta_value (already figure it out ). The problem is to insert the empty meta_key = '_woosea_brand" if meta_key = 'woocommerce_ceneo_Producent' exist.

I was trying this code: I found it in another stackoverflow post. But it change meta_value.

PhPmyadmin SQL Query to insert meta_key & value IF another value exist

INSERT INTO wp_postmeta (meta_key, meta_value, post_id)
SELECT "_wplp_post_front", 1, post_id
 FROM wp_postmeta outside_table
 WHERE meta_key = 'qty'
 AND meta_value = '0'
 AND NOT EXISTS 
(SELECT * FROM wp_postmeta
WHERE post_id = outside_table.post_id
AND meta_key = "_wplp_post_front"
AND meta_value = 1
)

1 Answers1

0

OK i think I found solution:

INSERT INTO wplw_postmeta (post_id, meta_key, meta_value)

SELECT post_id, '_woosea_brand', meta_value FROM wplw_postmeta WHERE meta_key='woocommerce_ceneo_Producent'