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 '188 or terms.term_id = 453) and categories.category_id = terms.category_id GRO' at line 1 SELECT terms.term_id, terms.term, terms.category_id, terms.path as terms_path, categories.category_id, categories.category, categories.path as categories_path FROM terms, categories where ( terms.term_id = 381 or terms.term_id = 590 or terms.term_id = 44 or terms.term_id = 459. 188 or terms.term_id = 453) and categories.category_id = terms.category_id GROUP BY terms.term