所以我的情況是這樣的。我有下面的查詢來獲取數據庫中的帖子,在LIKE
內使用的字來自input text
和month
來自select tag
。所以當我鍵入Brescia
在input box
它提取brescia
這是正確的結果,但是當我選擇month
與brescia
它確實只返回與brescia
職位,並不去月掃描。我有月份字段,如:man_date
格式2015-04-12
。從表中選擇和月份()= 4
SELECT wp_posts.*,MONTH(wp_posts.man_date) as month
FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_taxonomy
ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
INNER JOIN wp_locations
ON (wp_posts.ID = wp_locations.post_id)
WHERE wp_term_taxonomy.taxonomy = 'tipo_manifestazione'
AND wp_term_taxonomy.term_id = 97 AND wp_posts.post_type = 'manifestazione' AND MONTH(wp_posts.man_date) = 4
AND wp_posts.post_status = 'publish'
AND wp_posts.vip = 'NULL'
AND wp_locations.continente LIKE '%Brescia%'
OR wp_locations.nazione LIKE '%Brescia%'
OR wp_locations.regione LIKE '%Brescia%'
OR wp_locations.citta LIKE '%Brescia%'
OR wp_locations.luogo LIKE '%Brescia%'
GROUP BY wp_posts.ID
ORDER BY wp_posts.ID DESC
我的查詢通過搜索返回帖子,但是使用上面的查詢返回0. –