我有一個查詢,這是一個wordpress查詢的自定義搜索,它工作正常,但這裏是一些會員訂閱和用戶無法找到帖子,如果論壇是隻爲「金」訂閱SQL NOT LIKE「%term%」mot工作
而現在它顯示我想修改查詢到像顯示所有除AND (post_forum_meta.meta_value NOT LIKE '%gold%')
我加入的職位元所有用戶 所有帖子(免費和金)通過ID發佈父母論壇,然後尋找meta_value(免費/金)
SELECT SQL_CALC_FOUND_ROWS
DISTINCT wp_posts.ID FROM wp_posts
LEFT JOIN wp_postmeta as meta_1 ON wp_posts.ID = meta_1.post_id
LEFT JOIN wp_postmeta as event_venue_meta ON meta_1.meta_value = event_venue_meta.post_id
LEFT JOIN wp_postmeta as post_forum_meta ON meta_1.meta_value = post_forum_meta.post_id AND meta_1.meta_key='_bbp_forum_id'
LEFT JOIN wp_term_relationships as tax_relation ON wp_posts.ID = tax_relation.object_id
INNER JOIN wp_term_taxonomy as tax_term ON tax_term.term_taxonomy_id = tax_relation.term_taxonomy_id
INNER JOIN wp_terms as term ON term.term_id = tax_term.term_id
LEFT JOIN wp_icl_translations t
ON wp_posts.ID = t.element_id
AND t.element_type = CONCAT('post_', wp_posts.post_type)
WHERE 1=1
AND (((wp_posts.post_title LIKE '%search%')
AND (post_forum_meta.meta_value NOT LIKE '%gold%')
OR (meta_1.meta_key='_tribe_event_speaker' AND meta_1.meta_value LIKE '%search%')
OR (meta_1.meta_key='_EventStartDate' AND meta_1.meta_value LIKE '%search%')
OR (event_venue_meta.meta_key='_VenueAddress' AND event_venue_meta.meta_value LIKE '%search%')
OR (term.name LIKE '%search%')
OR (wp_posts.post_excerpt LIKE '%search%')
OR (wp_posts.post_content LIKE '%search%')
))
AND wp_posts.post_type IN ('post', 'tribe_events', 'topic')
AND ((wp_posts.post_status = 'publish'))
AND ((t.language_code = 'de' AND wp_posts.post_type IN ('post','page','forum','product','product_variation','tribe_venue','tribe_organizer','tribe_events','tribe_wooticket') ));
我曾嘗試用NULL NOT LIKE等,但沒有
所以我需要的是讓所有除 「金」 的帖子... 這裏是我的表:
AND和OR沒有括號 - 總是導致問題 –