An Error Was Encountered

Error Number: 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 'AND tertiary_2.table_group = 'collection' WHERE catalogue.archived = 'no' ORDER ' at line 4

SELECT catalogue.title, catalogue.id, catalogue.slug FROM (`catalogue`) INNER JOIN `tertiary` as tertiary_1 ON tertiary_1.primary_id = catalogue.id AND tertiary_1.category_id = 4 AND tertiary_1.table_group = 'category' INNER JOIN `tertiary` as tertiary_2 ON tertiary_2.primary_id = catalogue.id AND tertiary_2.category_id = AND tertiary_2.table_group = 'collection' WHERE catalogue.archived = 'no' ORDER BY tertiary_1.rank DESC, tertiary_2.rank DESC