Question about EXISTS - Mailing list pgsql-general

From Excite Holidays
Subject Question about EXISTS
Date
Msg-id CAFJQeEMhHh=3Gnw6m8G0ZdjArCqRvT3XQYqn+fe+cuRcqOS7bQ@mail.gmail.com
Whole thread Raw
Responses Re: Question about EXISTS  (David Johnston <polobo@yahoo.com>)
List pgsql-general
Hi,

I have been making some test with EXISTS and I found I case that I do not understand too well:

CREATE TABLE testing (
number_id serial,
number1 integer,
number2 integer
);
INSERT INTO testing (number1, number2) VALUES (1,1),(1,2),(2,3);

SELECT *
FROM testing
WHERE EXISTS (SELECT 1 FROM testing WHERE testing.number_id = number_id AND number1 = 1);

As far I understand the documentation the select query should return row 1 and 2, but it is returning 1, 2 and 3.

Why is this happening ?

PS_ PostgreSQL 9.1.1 on i686-pc-linux-gnu, compiled by gcc (Debian 4.3.2-1.1) 4.3.2, 32-bit

Regards,
Ruben



pgsql-general by date:

Previous
From: Chris Travers
Date:
Subject: Re: Feature discussion: Should syntax errors abort a transaction?
Next
From: David Johnston
Date:
Subject: Re: Question about EXISTS