Running this query:
SELECT EXISTS (select true from "MyGroup" WHERE "UserID"=3 AND "GroupID"=17);
Returned result is:
exists
-------
t
(1 row)
It should not exist. There is no Group with ID 17. Confirmed in PGAdmin.
In fact, any arbitrary UserID and GroupID (e.g. 355, 267) returns the same result. What is wrong here?
Thanks
There is something wrong with your condition because it works as expected for me:
select exists (select true where false);
exists
--------
f
SELECT * FROM MyGroup WHERE EXISTS(select true from MyGroup WHERE UserID=3 AND GroupID=17)
Another example
SELECT *FROM products WHERE EXISTS (SELECT 1
FROM inventory
WHERE products.product_id = inventory.product_id);