Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do Minus HQL

I have a table A{id, foo, ...} and a table B{id, boo, idA} I want All objects in A that the ids doesn't appear in B

in Oracle SQL would looks like:

SELECT id FROM A MINUS( SELECT idA FROM B);
like image 568
xedo Avatar asked Dec 18 '13 09:12

xedo


2 Answers

MINUS function not exists in HQL, go here on paragraph 14.10 Expressions.

Try this:

SELECT id FROM A
WHERE NOT EXISTS
    (SELECT 'X' FROM B WHERE B.idA = A.id)
like image 134
Joe Taras Avatar answered Sep 18 '22 22:09

Joe Taras


Is easier than I supposed, I was focused in the minus

select a.id from A as a where a.id not in (select idA from B)

thanks

like image 31
xedo Avatar answered Sep 20 '22 22:09

xedo