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 ') GROUP BY P.id ORDER BY P.sort_ord...' at line 13 SELECT DISTINCT P.*, PHM.marca_id brand_id, PHC.categoria_id categoria_id, PHA.valor_atributo_id valor_atributo_id, PHA.atributo_id atributo_id, JSON_EXTRACT_BRIGHT(P.url, '$.pt') url FROM produtos P LEFT JOIN produtos_has_marcas PHM ON PHM.produto_id = P.id LEFT JOIN produtos_has_atributos PHA ON PHA.produto_id = P.id LEFT JOIN produtos_has_categorias PHC ON PHC.produto_id = P.id LEFT JOIN variacao V ON V.produto_id = P.id WHERE P.is_active = 1 AND (P.stock > 0 OR P.product_soon = 1) AND P.preco > 0 AND PHC.categoria_id IN () GROUP BY P.id ORDER BY P.sort_order asc