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

2022-10-25 Thread Rob Sargent

On 10/25/22 09:58, David G. Johnston wrote:

On Tue, Oct 25, 2022 at 8:56 AM Rob Sargent  wrote:

On 10/25/22 09:24, David G. Johnston wrote:

On Tue, Oct 25, 2022 at 8:22 AM David G. Johnston
 wrote:

On Tue, Oct 25, 2022 at 7:06 AM Rob Sargent
 wrote:



2: select * from table join table b on Id = idb



#2 is probably conceptually correct but in this context
should be written as:


Actually, a join is NOT conceptually correct here - the output
columns for "SELECT *" will be wrong.

David J.


OK.  TBH I thought this was the JOOQ list! Didn't notice the
typedef.  So this is all about exact match "tables".

I suppose my #2 could be framed as
select a* from table as a join table as b on a. =
b.
to be a functional equivalent of INTERSECT?


SELECT DISTINCT a.*

David J.

Yeah, sorry.  Meant to distinguish to two "table" defs in some way.

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

2022-10-25 Thread David G. Johnston
On Tue, Oct 25, 2022 at 8:56 AM Rob Sargent  wrote:

> On 10/25/22 09:24, David G. Johnston wrote:
>
> On Tue, Oct 25, 2022 at 8:22 AM David G. Johnston <
> david.g.johns...@gmail.com> wrote:
>
>> On Tue, Oct 25, 2022 at 7:06 AM Rob Sargent 
>> wrote:
>>
>>>
>>>
>>> 2: select * from table join table b on Id = idb
>>>
>>>
>>>
>> #2 is probably conceptually correct but in this context should be written
>> as:
>>
>>
> Actually, a join is NOT conceptually correct here - the output columns for
> "SELECT *" will be wrong.
>
> David J.
>
> OK.  TBH I thought this was the JOOQ list! Didn't notice the typedef.  So
> this is all about exact match "tables".
>
> I suppose my #2 could be framed as
> select a* from table as a join table as b on a. =
> b.
> to be a functional equivalent of INTERSECT?
>

SELECT DISTINCT a.*

David J.


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

2022-10-25 Thread Rob Sargent

On 10/25/22 09:24, David G. Johnston wrote:
On Tue, Oct 25, 2022 at 8:22 AM David G. Johnston 
 wrote:


On Tue, Oct 25, 2022 at 7:06 AM Rob Sargent
 wrote:



2: select * from table join table b on Id = idb



#2 is probably conceptually correct but in this context should be
written as:


Actually, a join is NOT conceptually correct here - the output columns 
for "SELECT *" will be wrong.


David J.

OK.  TBH I thought this was the JOOQ list! Didn't notice the typedef.  
So this is all about exact match "tables".


I suppose my #2 could be framed as
select a* from table as a join table as b on a. = b.
to be a functional equivalent of INTERSECT?


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

2022-10-25 Thread David G. Johnston
On Tue, Oct 25, 2022 at 8:22 AM David G. Johnston <
david.g.johns...@gmail.com> wrote:

> On Tue, Oct 25, 2022 at 7:06 AM Rob Sargent  wrote:
>
>>
>>
>> 2: select * from table join table b on Id = idb
>>
>>
>>
> #2 is probably conceptually correct but in this context should be written
> as:
>
>
Actually, a join is NOT conceptually correct here - the output columns for
"SELECT *" will be wrong.

David J.


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

2022-10-25 Thread David G. Johnston
On Tue, Oct 25, 2022 at 7:06 AM Rob Sargent  wrote:

>
>
> On Oct 25, 2022, at 7:55 AM, jack...@gmail.com wrote:
>
> 
>
> typedef enum SetOperation
> {
> SETOP_NONE = 0,
> SETOP_UNION,
> SETOP_INTERSECT,
> SETOP_EXCEPT
> } SetOperation;
> --
> jack...@gmail.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.


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

2022-10-25 Thread jack...@gmail.com


> On Oct 25, 2022, at 7:55 AM, jack...@gmail.com wrote:
> 
> 
> 
> typedef enum SetOperation
> {
> SETOP_NONE = 0,
> SETOP_UNION,
> SETOP_INTERSECT,
> SETOP_EXCEPT
> } SetOperation;
> jack...@gmail.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



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

2022-10-25 Thread Rob Sargent


> On Oct 25, 2022, at 7:55 AM, jack...@gmail.com wrote:
> 
> 
> 
> typedef enum SetOperation
> {
> SETOP_NONE = 0,
> SETOP_UNION,
> SETOP_INTERSECT,
> SETOP_EXCEPT
> } SetOperation;
> jack...@gmail.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