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.campaignId=131' at line 3

SELECT A.* ,(SELECT IFNull(Sum(View),0) FROM `tbl_basicontent` WHERE `messageId` = A.id) As ViewCount, (SELECT IFNull(Sum(`uniqueview`),0) FROM `tbl_basicontent` WHERE `messageId` = A.id) As uniqueviewCount FROM `tbl_messages` A WHERE A.user_id = '' AND A.profile_id= And A.campaignId=131