UPDATE wp_posts AS P
LEFT JOIN wp_postmeta AS Latitude
ON Latitude.meta_key='lv_listing_lat' AND P.ID=Latitude.post_id
LEFT JOIN wp_postmeta AS Longtitude
ON Longtitude.meta_key='lv_listing_lng' AND P.ID=Longtitude.post_id
SET P.post_status='trash'
WHERE P.post_type='lv_listing'
AND Latitude.meta_value... //duplicate clause
AND Latitude.meta_value .... //duplicate clause
请帮帮我!非常感谢
来自Wordpress数据库的这些数据
答案 0 :(得分:0)
您可以在此处使用加入条件进行更新
UPDATE p SET P.post_status='trash'
from p_posts AS P
LEFT JOIN wp_postmeta AS Latitude ON Latitude.meta_key='lv_listing_lat' AND P.ID=Latitude.post_id
LEFT JOIN wp_postmeta AS Longtitude ON Longtitude.meta_key='lv_listing_lng' AND P.ID=Longtitude.post_id
WHERE P.post_type='lv_listing'
表示重复的行(尝试这个不确定它是否有效:))
UPDATE p SET P.post_status='trash'
from p_posts AS P
LEFT JOIN wp_postmeta AS Latitude ON Latitude.meta_key='lv_listing_lat' AND P.ID=Latitude.post_id
LEFT JOIN wp_postmeta AS Longtitude ON Longtitude.meta_key='lv_listing_lng' AND P.ID=Longtitude.post_id
WHERE P.post_type='lv_listing' and Longtitude.meta_value in (Select Longtitude.meta_value from p_posts AS P
LEFT JOIN wp_postmeta AS Latitude ON Latitude.meta_key='lv_listing_lat' AND P.ID=Latitude.post_id
LEFT JOIN wp_postmeta AS Longtitude ON Longtitude.meta_key='lv_listing_lng' AND P.ID=Longtitude.post_id
WHERE P.post_type='lv_listing' group by Longtitude.meta_value having count(Longtitude.meta_value)>1)