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 ') group by deal_id ) x LIMIT 1' at line 2select count(*) as count from ( select * from deals_data where end_on>='2020-01-23' and is_deleted='0' and deal_status='1' and category_id in (77,85,86,88,89,95,96,103,104,107,128,129,130,131,133,136,141,143,144,145,158,161,178,187,195,200,209,235,236,237,254,327,335,340,403,525,578,612,638,660,661,675,687,790,1370,1420,1456,1491,1503,1525,1535,1546,1548,1550,1552,1560,1561,1568,1571,1592,1594,1610,1612,1613,1624,1633,1636,1645,1646,1647,1649,1651,1652,1654,1655,1657,1658,1667,1673,1674,1677,1678,1679,1684,1685,1687,1688,1690,1693,1694,1695,1696,1701,1705,1707,1710,1711,1712,1713,1715,1716,1717,1718,1719,1720,1721,1727,1728,1731,1733,1735,1736,1737,1738,1740,1746,1748,1749,1752,1757,1777,1778,1780,1781,1782,1797,1799,1807,1808,1809,1810,1813,1814,1815,1821,1822,1823,1824,1828,1830,1837,1838,1842,1843,1856,1859,1860,1863,1865,1866,1867,1884,1889,1892,1893,1894,1895,1897,1909,1914,1918,1921,1936,1945,1948,1951,1961,1969,1979,1983,1984,1989,1995,1998,2004,2014,2020,2021,2025,2026,2028,2036,2038,2042,2046,2047,2050,2078,2092,2094,2126,2138,2139,2145,2152,2157,2163,2165,2166,2177,2188,2199,2206,2209,2257,2288,2296,2298,2300,2310,2327,2328,2339,2352,2363,) group by deal_id ) x LIMIT 1