我有2个查询,如下所示,
A SELECT DISTINCT meta_value, meta_id FROM `wp_postmeta` WHERE `meta_key`='destination';
B SELECT ID FROM wp_posts WHERE post_status = 'publish';
我想要的是这样的,
SELECT meta_value FROM A WHERE A.meta_id = B.ID;
答案 0 :(得分:0)
SELECT DISTINCT
meta_value
FROM `wp_postmeta` wpm,
wp_posts wp
WHERE wp.ID = wpm.meta_id
AND wpm.`meta_key` = 'destination'
AND wp.post_status = 'publish';
答案 1 :(得分:0)
试试这个
SELECT A.meta_value, A.meta_id
FROM `wp_postmeta` A
INNER JOIN wp_posts B
ON meta_id = id
WHERE A.`meta_key`= 'destination'
AND B.post_status = 'publish'
GROUP BY A.meta_value