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 a.recommended =1 ORDER BY a.changetime' at line 1
The Query is: SELECT count(*) as rowCount FROM msw_brandproduct a INNER JOIN msw_brandcompinfo b ON a.compid = b.compid WHERE a.compid = AND a.recommended =1 ORDER BY a.changetime