here is my query
$sql = 'SELECT users.userId as userId
FROM App\UserProjects up
LEFT JOIN up.user users
WHERE up.project = :project AND FIND_IN_SET(:comp, up.company)';
$query = $this->getEntityManager()->createQuery($sql);
$query->setParameter('project', 3);
$query->setParameter('comp', 4);
$results = $query->getResult();
But this gives me the error
[Syntax Error] line 0, col -1: Error: Expected =, <, <=, <>, >, >=, !=, got end of string.
What am i doing wrong? Is there a work around? and the field i am searching in has comma seperated values, if FIND_IN_SET is not working, is there any other way i can do the same query?
and i am using this extension https://github.com/beberlei/DoctrineExtensions
FIND_IN_SET
give you the index of the searched element. You have to compare it to something:
FIND_IN_SET(:comp, up.company) != 0
You should use IN
instead, it doesn't need any extension
AND :comp IN up.company
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With