我有一个查询...
SELECT p.*
FROM wp_posts p
JOIN wp_postmeta pm
ON pm.post_id = p.ID
JOIN wp_postmeta pmd
ON pmd.post_id = p.ID
WHERE p.post_type = 'event'
AND p.post_status = 'publish'
AND ( pm.meta_key = 'post_city_id'
AND ( pm.meta_value = '1' ) )
AND ( pmd.meta_key = 'end_date'
AND pmd.meta_value >= '2012-05-27' )
ORDER BY p.post_date ASC,
p.post_title ASC
LIMIT 5
end_date 和 end_time 是元键,其值与特定帖子不应再显示在网站上的日期(以 Ymd 格式)和时间等价。所以我想用 pmd.meta_key='end_date' asc,pmd.meta_key='end_time' asc 之类的东西更改 p.post_date asc,但我不确定最好的方法。有什么想法吗?