SQL WordPress获取序列化元值大于今天日期的帖子

时间:2015-02-17 19:43:25

标签: php sql wordpress

我已将一大堆后元数据存储在序列化数组中,我试图编写一个自定义SQL查询,只检索即将发布的结果:

我目前处于以下状态,但似乎并不想得到结果。

我输出的SQL是:

SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND wp_posts.post_type = 'cjd' AND ((wp_posts.post_status = 'publish')) AND ( ( wp_postmeta.meta_key = 'cjd_data' AND CAST(wp_postmeta.meta_value AS SIGNED) >= 'date' ) ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date ASC

我的功能是:

$wpdb->query( 
$wpdb->prepare( "SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND wp_posts.post_type = 'cjd' AND ((wp_posts.post_status = 'publish')) AND ( ( wp_postmeta.meta_key = 'cjd_data' AND CAST(wp_postmeta.meta_value AS SIGNED) >= 'date' ) ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date ASC")
);

我已尝试过所有内容,因为日期字段位于序列化数组中,所以我无法在自定义$ args上使用meta_query。

0 个答案:

没有答案