testing spirits

WordPress database error: [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 'or wptm.term_id=' at line 18]
SELECT wtt.taxonomy, wtt.parent as parent_, wt2.name as parent_cat, wtt.description, wt.name, wt.slug, wptm.term_id, wptm.meta_value, wptm2.meta_value as featured_bar, wp.guid from wp_term_taxonomy wtt left join wp_terms wt on (wt.term_id = wtt.term_id ) left join wp_termmeta wptm on (wptm.term_id = wt.term_id and wptm.meta_key = 'featured_image') left join wp_termmeta wptm2 on (wptm2.term_id = wt.term_id and wptm2.meta_key = 'is_featured_bar') left join wp_posts wp on (wp.id = wptm.meta_value) left join wp_terms wt2 on (wtt.parent = wt2.term_id) where wtt.taxonomy ='category' and wtt.parent= or wptm.term_id=