-1

i want to use inner join query for merging 4 tables. and i had written query like this.

    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

However it will show syntex error like this

#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, 25' at line 1

please help me to solve this error.

Nisarg Bhavsar
  • 946
  • 2
  • 18
  • 40
  • move your where statement before the order by, try running the query against your database directly using something like phpMyAdmin or MysqlWorkbench – Scriptable Apr 04 '15 at 10:04

1 Answers1

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

use like this

Vivek Singh
  • 2,453
  • 1
  • 14
  • 27