Subquery Error: Expected =, <, <=, <>, >, >=, !=, got 'LIKE' #5352

Open
opened 2026-01-22 15:05:13 +01:00 by admin · 0 comments
Owner

Originally created by @johnzuk on GitHub (Dec 20, 2016).

Originally assigned to: @Ocramius on GitHub.

I have a mysql query:

SELECT COUNT(c.id) FROM company c WHERE (SELECT MIN(u.surname) FROM contact u WHERE u.company_id = c.id) LIKE '%a%'

it works perfectly. If i try to transfer it in to doctrine like that:

$this->getDoctrine()->getManager()
            ->getRepository('XYZBundle:Company')
            ->createQueryBuilder('c')
            ->select('COUNT(c.id)')
            ->where("(SELECT MIN(u.surname) FROM XYZBundle:Contact u where u.id = c.id) LIKE '%a%'")
            ->getQuery()
            ->getResult();

doctrine throw
QueryException: [Syntax Error] line 0, col 136: Error: Expected =, <, <=, <>, >, >=, !=, got 'LIKE' '
If i change LIKE into = subquery works. But i need LIKE, how can i do that?

Originally created by @johnzuk on GitHub (Dec 20, 2016). Originally assigned to: @Ocramius on GitHub. I have a mysql query: ```sql SELECT COUNT(c.id) FROM company c WHERE (SELECT MIN(u.surname) FROM contact u WHERE u.company_id = c.id) LIKE '%a%' ``` it works perfectly. If i try to transfer it in to doctrine like that: ```php $this->getDoctrine()->getManager() ->getRepository('XYZBundle:Company') ->createQueryBuilder('c') ->select('COUNT(c.id)') ->where("(SELECT MIN(u.surname) FROM XYZBundle:Contact u where u.id = c.id) LIKE '%a%'") ->getQuery() ->getResult(); ``` doctrine throw `QueryException: [Syntax Error] line 0, col 136: Error: Expected =, <, <=, <>, >, >=, !=, got 'LIKE' '` If i change **LIKE** into **=** subquery works. But i need LIKE, how can i do that?
admin added the Invalid label 2026-01-22 15:05:13 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5352