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 'ORDER BY rand() DESC LIMIT 4' at line 1 1064 SELECT * FROM `mcy_content` WHERE description_en!='' and sid= ORDER BY rand() DESC LIMIT 4