I have a table with these fields:
ID (Primary key)
Name
Some more data fields
I want to write a query that given a Name will give me all the rows with ID’s bigger then the row with that name.
(Yes yes I know the name is not unique… in the system is.)
I want something like:
select *
From SomeTable as x
WHERE x.ID> (Select ID from SomeTable as y where y.Name LIKE :param)
or:
SELECT x
FROM SomeTable as x
JOIN SomeTable as y ON x.ID > Y.ID
WHERE Y.Name LIKE :Param
Of course I want the self join, and not the sub query.
BTW.
Criteria goes too…
You won’t be able to do it with a join in HQL.
But this HQL query is OK:
If the subselect might return several IDs, you may also use