Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
SELECT EXISTS always returning same result

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

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

There is something wrong with your condition because it works as expected for me:

select exists (select true where false);
 exists 
--------
 f
over 4 years ago · Santiago Trujillo Report

0

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);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!