伙计我被困在MySql查询上。以下是我对数据库中SELECT
数据的查询。我停留在Update
查询以更新Price
。
Select Query
SELECT p.id, p.post_title, m.meta_key as Type, m.meta_value as SKU ,k.meta_value as price
FROM wp8k_posts p
INNER JOIN wp8k_postmeta m ON p.id=m.post_id
AND m.meta_key='_sku'
INNER JOIN wp8k_postmeta k ON p.id=k.post_id
AND k.meta_key='_sale_price'
where m.meta_value= 'GLC-LH-SM'
Update Query
Update wp8k_postmeta k
INNER JOIN wp8k_posts p ON p.id=m.post_id
AND m.meta_key='_sku'
INNER JOIN wp8k_postmeta k ON p.id=k.post_id
AND k.meta_key='_sale_price'
set k.meta_key = 90
where m.meta_value= 'GLC-LH-SM'
任何人都可以帮忙。
答案 0 :(得分:0)
您必须对所有表使用唯一别名:
Update wp8k_postmeta k
INNER JOIN wp8k_posts p ON p.id=k.post_id AND k.meta_key='_sale_price'
INNER JOIN wp8k_postmeta m ON p.id=m.post_id AND m.meta_key='_sku'
set k.meta_key = 90
where m.meta_value= 'GLC-LH-SM'