You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Αντώνης Λεμπέσης <an...@di.uoa.gr> on 2005/06/17 16:25:53 UTC
query with "exists" clause
Hello,
I have these two tables:
doc(id, title) and
rel(source, target) (both 'source' and 'target' are foreign keys to
doc.id)
I want to form the following query, using Criteria:
SELECT d1.title
FROM doc d1
WHERE EXISTS (
SELECT *
FROM doc d2, rel r
WHERE r.source = d1.id AND r.target = d2.id AND d2.title = 'foo')
Any ideas on how to do this???
Thanks,
Antonis
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
RE: query with "exists" clause
Posted by Thomas Fischer <fi...@seitenbau.net>.
Hi,
subselects are not supported out of the box in Torque. there are various
threads in the user mailing list of how they can be implemented, the last
one should be only a few weeks ago. Please search the archives. The
solution involves Criteria.CUSTOM, but I cannot remember exactly how it
works.
Thomas
Αντώνης Λεμπέσης <an...@di.uoa.gr> schrieb am 17.06.2005 16:25:53:
> Hello,
>
> I have these two tables:
> doc(id, title) and
> rel(source, target) (both 'source' and 'target' are foreign keys to
> doc.id)
>
> I want to form the following query, using Criteria:
>
> SELECT d1.title
> FROM doc d1
> WHERE EXISTS (
> SELECT *
> FROM doc d2, rel r
> WHERE r.source = d1.id AND r.target = d2.id AND d2.title = 'foo')
>
> Any ideas on how to do this???
>
> Thanks,
> Antonis
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>