array(21) { [3972]=> int(3972) [4873]=> int(4873) [3911]=> int(3911) [117]=> int(117) [3978]=> int(3978) [3878]=> int(3878) [4657]=> int(4657) [4944]=> int(4944) [3890]=> int(3890) [3968]=> int(3968) [25]=> int(25) [4754]=> int(4754) [4473]=> int(4473) [4875]=> int(4875) [4849]=> int(4849) [4631]=> int(4631) [4493]=> int(4493) [4485]=> int(4485) [4486]=> int(4486) [4480]=> int(4480) [4847]=> int(4847) } 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 a.id IN ( SELECT a2.id ...' at line 6