Question about EXISTS

Поиск
Список
Период
Сортировка
От Excite Holidays
Тема Question about EXISTS
Дата
Msg-id CAFJQeEMhHh=3Gnw6m8G0ZdjArCqRvT3XQYqn+fe+cuRcqOS7bQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: Question about EXISTS  (David Johnston <polobo@yahoo.com>)
Список 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 по дате отправления:

Предыдущее
От: Chris Travers
Дата:
Сообщение: Re: Feature discussion: Should syntax errors abort a transaction?
Следующее
От: David Johnston
Дата:
Сообщение: Re: Question about EXISTS