Re: postgresql vs mysql

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: postgresql vs mysql
Дата
Msg-id 200702211835.08723.peter_e@gmx.net
обсуждение исходный текст
Ответ на Re: postgresql vs mysql  ("Adam Rich" <adam.r@sbcglobal.net>)
Список pgsql-general
Adam Rich wrote:
> -- Query A
> select count(*) from customers c
> where not exists ( select 1 from orders o
> where o.customer_id = c.customer_id )
>
> -- Query B
> select count(*) from customers c
> where customer_id not in ( select customer_id from orders)
>
> -- Query C
> select count(*) from customers c
> left join orders o on c.customer_id = o.customer_id
> where o.order_id is null
>
> I believe they all achieve the same thing.

I think not.  When using

INSERT INTO customers VALUES (1);
INSERT INTO customers VALUES (2);
INSERT INTO customers VALUES (NULL);

and

INSERT INTO orders VALUES (1);
INSERT INTO orders VALUES (3);
INSERT INTO orders VALUES (NULL);

I get

Query A: 2
Query B: 0
Query C: 3

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

В списке pgsql-general по дате отправления:

Предыдущее
От: Michelle Konzack
Дата:
Сообщение: Quering 4 or more physicale different PostgreSQL server at once
Следующее
От: "Ian Harding"
Дата:
Сообщение: Re: Recursive Left Joins Causing Trouble in 8.2.3 RESOLVED (kind of)