SELECT MIN(price) AS min_price, MAX(price) AS max_price FROM adverts a JOIN categories_last CL on CL.advertCategory=a.categoryID WHERE CL.searchCategory = AND active='yes'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 active='yes'' at line 6