-1

我有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;
4

2 回答 2

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';
于 2013-05-29T10:17:32.840 回答
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
于 2013-05-29T10:24:06.760 回答