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 '-30, 30' at line 1Select * from `photo_gallery`,`photo_categories` where `photo_categories`.`category_id` = `photo_gallery`.`category_id` and `photo_gallery`.`is_active` ='1' group by `photo_categories`.`category_id` order by `photo_categories`.`category_name` asc LIMIT -30, 30