在内部联接中使用where子句查询

时间:2015-04-04 10:03:01

标签: mysql wordpress

我想使用内部联接查询来合并4个表。我写了这样的查询。

    select t.name,t.slug,tt.term_taxonomy_id,tt.description,tr.object_id,p.post_content,p.post_title,pm.meta_value from wp_terms as t join wp_term_taxonomy as tt on tt.term_id = t.term_id join wp_term_relationships as tr on tr.term_taxonomy_id = tt.term_taxonomy_id join wp_posts as p on p.ID = tr.object_id join wp_postmeta as pm on pm.post_id = p.ID AND pm.meta_key = 'zgir_df252314' order by pm.meta_value where t.term_id = 101

然而,它会像这样显示syntex错误

#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 'where t.term_id = 101

在第1行限制0,25'

请帮我解决这个错误。

1 个答案:

答案 0 :(得分:0)

 where t.term_id = 101 order by pm.meta_value

像这样使用