我正在尝试查询wordpress db。但是我收到了这个错误,我无法弄明白。任何人都可以帮助我。
查询:
SELECT DISTINCT aub_terms.* FROM aub_term_relationships
JOIN aub_posts ON aub_posts.ID = aub_term_relationships.object_id
JOIN aub_term_taxonomy ON aub_term_taxonomy.term_taxonomy_id = aub_term_taxonomy.term_taxonomy_id
JOIN ON aub_term_taxonomy.term_id = aub_terms.term_id
WHERE `aub_term_taxonomy`.`taxonomy` = 'post_tag'
AND aub_posts.ID IN (254,239,175,150,119,65,63,61,59,54,51);
错误:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON aub_term_taxonomy.term_id = aub_terms.term_id WHERE `aub_term_taxonomy`.`taxo' at line 1
答案 0 :(得分:1)
你没有在任何地方访问“aub_terms”表... 试试这个:
SELECT DISTINCT aub_terms.*
FROM aub_term_relationships
JOIN aub_posts ON aub_posts.ID = aub_term_relationships.object_id
JOIN aub_term_taxonomy ON aub_term_taxonomy.term_taxonomy_id = aub_term_taxonomy.term_taxonomy_id
JOIN aub_terms ON aub_term_taxonomy.term_id = aub_terms.term_id
WHERE `aub_term_taxonomy`.`taxonomy` = 'post_tag'
AND aub_posts.ID IN (254,239,175,150,119,65,63,61,59,54,51);
答案 1 :(得分:0)
您的第3个JOIN不包含表名。我想,您的查询应该如下所示:
SELECT DISTINCT aub_terms.* FROM aub_term_relationships
JOIN aub_posts ON aub_posts.ID = aub_term_relationships.object_id
JOIN aub_term_taxonomy ON aub_term_taxonomy.term_taxonomy_id = aub_term_taxonomy.term_taxonomy_id
JOIN aub_terms ON aub_term_taxonomy.term_id = aub_terms.term_id
WHERE `aub_term_taxonomy`.`taxonomy` = 'post_tag'
AND aub_posts.ID IN (254,239,175,150,119,65,63,61,59,54,51);