2016-07-29 63 views
0

我有一個表,看起來像下面的圖片:設置2行的值相同ROW1值,其列相同

enter image description here

在這裏,我有顯着的兩排。有兩個不同的元鍵,一個是_regular_price,另一個是_price

現在我想更新meta_value的_price meta_key,並設置價格爲_regular_price

那麼,我應該寫什麼查詢?

回答

1

您可以使用自聯接:

update yourtable t1 
join yourtable t2 
on t1.post_id = t2.post_id and t2.meta_key = '_regular_price' 
set t1.meta_value = t2.meta_value 
where t1.meta_key = '_price' 
0

這樣來做:

update table1 set meta_key= '_regular_price' where meta_id = 2364389 

希望它幫助。