1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 2

SELECT pages.* ,categories.name as category_name,( SELECT count(*) FROM images where set_id = pages.`gallery_id` ) as images_num, ( SELECT count(*) FROM videos where set_id = pages.`gallery_id` ) as videos_num FROM `pages` LEFT JOIN categories on pages.category_id = categories.id WHERE `pages`.category_id =