【发布时间】:2013-11-23 07:58:28
【问题描述】:
我在wordpress中运行查询成功。查询如下。
SELECT wp_posts.*, wp_postmeta.meta_value FROM wp_posts, wp_postmeta, wp_term_relationships, wp_terms
WHERE term_id = '12' AND term_taxonomy_id = '12' AND ID = post_id
AND ID = object_id AND post_type = 'property' AND post_status = 'publish'
AND meta_key = 'property_amount' AND replace( replace(meta_value, ',', ''), '"', '' ) >= 1
GROUP BY wp_posts.ID ORDER BY replace( replace(meta_value, ',', ''), '"', '' ) DESC
LIMIT 0, 10
但我想在上面的查询中再添加一个 meta_key 及其值条件,所以我将查询更改为这个
SELECT wp_posts.*, wp_postmeta.meta_value FROM wp_posts, wp_postmeta, wp_term_relationships, wp_terms
WHERE term_id = '12' AND term_taxonomy_id = '12' AND ID = post_id
AND ID = object_id AND post_type = 'property' AND post_status = 'publish'
AND meta_key = 'property_amount' AND replace( replace(meta_value, ',', ''), '"', '' )
>= 1
AND meta_key="property_land_type" and meta_value IN ('L','H','C')
GROUP BY wp_posts.ID ORDER BY replace( replace(meta_value, ',', ''), '"', '' ) DESC
LIMIT 0, 10
以下行在第一个查询中是额外的
meta_key="property_land_type" and meta_value in ('L','H','C')
但它不起作用。怎么做。这次我不能写 WP_Query,因为我有很多基于这个查询的其他查询。
提前致谢!!!
【问题讨论】:
-
你得到什么错误信息?