0

我正在尝试编写一个 sql 查询,如果它们匹配给定的整个术语集,它将返回帖子:

SELECT SQL_CALC_FOUND_ROWS wp_posts.ID 
FROM wp_posts 

LEFT JOIN wp_term_relationships AS trel ON (wp_posts.ID = trel.object_id) 
LEFT JOIN wp_term_taxonomy AS ttax ON (ttax.taxonomy = 'business-tags' AND trel.term_taxonomy_id = ttax.term_taxonomy_id) 
LEFT JOIN wp_terms AS tter ON (ttax.term_id = tter.term_id)

WHERE 1=1 
AND (tter.slug LIKE '%crazy%' AND tter.slug LIKE '%insane%')  
AND wp_posts.post_type = 'business' 
AND wp_posts.post_status = 'publish'

我在数据库中有一个包含这两个标签的帖子。现在,如果我只搜索一个标签,我会得到结果,但是当我搜索多个标签时,它会返回零结果。关于我可能做错了什么的任何建议?

4

0 回答 0