2015-04-04 83 views
-1

我想使用内部连接查询来合并4个表。我写过这样的查询。通过内部连接查询的顺序与where子句

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 

但是它会显示这样的

#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 

LIMIT 0了Syntex错误,25' 在行1

请帮我解决这个错误。

+0

通过订单之前将您的where语句,尝试直接使用的东西,像phpMyAdmin或MysqlWorkbench – Scriptable 2015-04-04 10:04:25

回答

0
where t.term_id = 101 order by pm.meta_value 

使用这样

+0

谢谢运行查询你的数据库。有用。 – 2015-04-04 10:07:05

+0

@nisarg检查我的答案正确.. – 2015-04-04 10:07:34