Check if identifier exists in external table twice

After trying for a while, I thought that I would try to make changes here.
I am trying to check if a person identifier exists in two tables, for one table it works like a charm, but if I try to check another table, I get the following error:

[Semantic error] row 0, column 268 next to 'owner FROM \ ... \ Entity \ Resource':
Error: invalid path. There must be a StateFieldPathExpression expression.

The trick is that I can only use one DQL query, and here is what I came up with (... not in a real query):

SELECT contact_person
FROM \\...\Entity\Person contact_person
WHERE NOT EXISTS (SELECT b.personId FROM \\...\Entity\Booking b WHERE b.personId = contact_person.id)
AND NOT EXISTS (SELECT r.owner FROM \\...\Entity\Resource r WHERE r.owner = contact_person.id)
+5
source share
2 answers

. , . ( DQL)

, , :

SELECT contact_person
FROM ...
WHERE (SELECT COUNT(b.personId) FROM \\...\Entity\Booking b WHERE b.personId=contact_person.id)=0
AND (SELECT COUNT...)=0

, , , . ( , , , , , ).

0

. . , , :

SELECT contact_person.*
FROM Person contact_person
LEFT JOIN Booking b  ON contact_person.id = b.personId
LEFT JOIN Resource r ON contact_person.id = r.owner
GROUP BY contact_person.id
HAVING COUNT(r.owner) = 0 AND COUNT(b.personId) = 0

, . .

PS. , DQL, , .

+1

All Articles