Re: Query regarding Intersect clause

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Query regarding Intersect clause
Дата
Msg-id 25968.1337180606@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Query regarding Intersect clause  (Ajit Pradnyavant <ajit.pradnyavant@gmail.com>)
Список pgsql-general
Ajit Pradnyavant <ajit.pradnyavant@gmail.com> writes:
> I think result of INTERSECT ALL query may be :

> Srno    Name
> 1    Aaaa
> 1    Aaaa

> Because  intersect all clause returns the duplicate values.

No; per the documentation at
http://www.postgresql.org/docs/9.1/static/sql-select.html#SQL-INTERSECT

    The result of INTERSECT does not contain any duplicate rows unless the
    ALL option is specified. With ALL, a row that has m duplicates in the
    left table and n duplicates in the right table will appear min(m,n)
    times in the result set.

So a single instance of Aaaa is appropriate for your example.  (This
definition is per the SQL standard btw.)

            regards, tom lane

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

Предыдущее
От: Evan Martin
Дата:
Сообщение: Re: Slow queries when functions are inlined
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Slow queries when functions are inlined