我正在尝试获取具有特定分类的帖子。在这种情况下,假设我要搜索分类为“电视”且值为“SON”的帖子,我无法确定要查询哪个表,因为电视似乎没有明确的 ID。每个电视实例都分配有一个新的 term_id 和 term_taxonomy_id。
我对需要加入哪个表以及哪些值有点困惑。
请有人给我一些建议,因为我想我已经把我秃头上剩下的头发拔掉了。谢谢。我的查询和数据库值如下,数据库图如下,
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID,
MIN(wp_offers.price)
FROM wp_posts
INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
LEFT JOIN wp_offers ON (wp_posts.ID = wp_offers.post_id)
WHERE DATE(wp_offers.offer_date) = '2012-05-18'
AND () # **********the query goes here**********
AND wp_term_relationships.term_taxonomy_id IN (8,9)
AND wp_posts.post_type = 'offer'
AND wp_posts.post_status = 'publish'
GROUP BY wp_posts.ID
ORDER BY wp_posts.post_title ASC
LIMIT 0, 15
**wp_term_relationships**
object_id term_taxonomy_id term_order
10 3 0
10 4 0
10 5 0
21 3 0
**wp_term_taxonomy**
term_taxonomy_id term_id taxonomy description parent count
3 3 television 0 2
4 4 television 0 1
5 5 television 0 1
**wp_terms**
term_id name slug term_group
3 SON SON 0
4 SAM SAM 0
5 TOS TOS 0