SELECT u.*, v.*,c.iconClass, c.name As category,c.clean_name as clean_category, v.created as videoCreation, ch.channelName,ch.channel_status, CONCAT(u.name,' ',u.lname) as username , COUNT(svc.vid_id) as totalsuggestion , (SELECT count(id) FROM video_ads as va where va.videos_id = v.id) as videoAdsCount, (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = 1 ) as likes, (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = -1 ) as dislikes FROM videos as v LEFT JOIN suggest_video_category svc ON(svc.vid_id = v.id) LEFT JOIN categories c ON FIND_IN_SET(c.id, v.categories_id) > 0 LEFT JOIN users u ON v.users_id = u.id LEFT JOIN channels ch ON v.channel_id = ch.id WHERE 1=1 AND v.id < AND v.del_status = '0' AND (SELECT count(id) FROM videos_group_view as gv WHERE gv.videos_id = v.id ) = 0 AND v.status IN ('a','i','e','x','d','xmp4','xwebm','xmp3','xogg','ximg','rep','ur') AND v.status = 'a' AND v.approve_status = '1' AND v.report_status!='2' AND v.upload_status ='1' AND u.status !='i' AND IF(v.channel_id = '0', u.channel_status='public', ch.channel_status='public') GROUP BY v.id ORDER BY v.id desc\nError : (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 'AND v.del_status = '0' AND (SELECT count(id) FROM videos_group_view as gv W...' at line 1