$query = $this->modelsManager->createQuery("SELECT * FROM product p WHERE cid > 1 AND (SELECT COUNT(*) FROM product p1 WHERE p1.cid = p.cid AND p.id <= p1.id) <= 4 ORDER BY p.id DESC");
return $query->execute();
Syntax error, unexpected token SELECT, near to ' COUNT(*) FROM product p1 WHERE p1.cid = p.cid AND p.id <= p1.id) <= 4 ORDER BY p.id DESC', when parsing: SELECT * FROM product p WHERE cid > 1 AND (SELECT COUNT(*) FROM product p1 WHERE p1.cid = p.cid AND p.id <= p1.id) <= 4 ORDER BY p.id DESC (138)
I want run subquery ........ help me.
SELECT * FROM product p WHERE cid > 1 AND (SELECT COUNT(*) FROM product p1 WHERE p1.cid = p.cid AND p.id <= p1.id) <= 4 ORDER BY p.id DESC