php - PhPmyadmin SQL Query to insert meta_key & value IF another value exist -
ok looking sql query insert meta_key & value in specific table if value exist. using wordpress database.
i want query search "wp_postmeta" table "qty (meta_key)" "0 (meta_value)" , insert posts new meta_key "_wplp_post_front" meta_value "1"
i new phpmyadmin , need help.
________________________update!!!
ok once again have found solution third party website:
insert wp_postmeta (meta_key, meta_value, post_id) select "_wplp_post_front", 1, post_id wp_postmeta outside_table meta_key = 'qty' , meta_value = '0' , not exists (select * wp_postmeta post_id = outside_table.post_id , meta_key = "_wplp_post_front" , meta_value = 1 )
ok once again have found solution third party website:
insert wp_postmeta (meta_key, meta_value, post_id) select "_wplp_post_front", 1, post_id wp_postmeta outside_table meta_key = 'qty' , meta_value = '0' , not exists (select * wp_postmeta post_id = outside_table.post_id , meta_key = "_wplp_post_front" , meta_value = 1 )
Comments
Post a Comment