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 trim_id in
(select trim_id from products where manufacturers_id=145 an' at line 1
select distinct trim_name from trims where model_id = and trim_id in
(select trim_id from products where manufacturers_id=145 and products_id in (select products_id from products_to_categories where categories_id in
(select categories_id from categories ))) order by trim_name