Re: please give me select sqls examples to distinct these!

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Rob Sargent <robjsargent(at)gmail(dot)com>
Cc: jacktby(at)gmail(dot)com, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: please give me select sqls examples to distinct these!
Date: 2022-10-25 15:22:44
Message-ID: CAKFQuwYvNChGg0-b+9siK0rNGj8Da-RAj3g9iy2kW=-rY1Uu8A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Oct 25, 2022 at 7:06 AM Rob Sargent <robjsargent(at)gmail(dot)com> wrote:

>
>
> On Oct 25, 2022, at 7:55 AM, jacktby(at)gmail(dot)com wrote:
>
> 
>
> typedef enum SetOperation
> {
> SETOP_NONE = 0,
> SETOP_UNION,
> SETOP_INTERSECT,
> SETOP_EXCEPT
> } SetOperation;
> ------------------------------
> jacktby(at)gmail(dot)com
>
>
> Please use just text.
> What ‘dialect’ are using? In Postgres
> 0: select * from table
> 1: select * from table union select * from table is same shape
> 2: select * from table join table b on Id = idb
> 3: select * from table except select * from tableb
>
>
#2 is probably conceptually correct but in this context should be written
as:

SELECT *
FROM table
INTERSECT
SELECT *
FROM table
Distinct is a default modifier, one can specify ALL if that isn't desired.

This is trivially answered by the documentation as well:

https://www.postgresql.org/docs/current/queries-union.html

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2022-10-25 15:24:32 Re: please give me select sqls examples to distinct these!
Previous Message David G. Johnston 2022-10-25 15:18:44 Re: can you give me a sql example to explain this?