Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1onOO0-0005U9-Gw for pgsql-general@arkaria.postgresql.org; Tue, 25 Oct 2022 18:10:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1onONx-0005BW-8j for pgsql-general@arkaria.postgresql.org; Tue, 25 Oct 2022 18:10:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1onONw-0005BN-Ji for pgsql-general@lists.postgresql.org; Tue, 25 Oct 2022 18:10:44 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1onONt-0007N4-5x for pgsql-general@lists.postgresql.org; Tue, 25 Oct 2022 18:10:42 +0000 Received: by mail-pj1-x1035.google.com with SMTP id z5-20020a17090a8b8500b00210a3a2364fso1988228pjn.0 for ; Tue, 25 Oct 2022 11:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=rSj5FyPyCz0V20bA8w3iGLLMGYT6Ukt8x3qbY2ASWtw=; b=eq+vWU9L+T8bhaBOCHSEgZr4kbfZd1vezrK8mkm1S+Y1PE41Ewuq/+BaXObPDegRPn h3RkhiWOhPzpXD6Hpb1dpXo9QtiYaWag0ZEwvlv5TJUM+STVGGo8Guby4xp6gi1OzVOl R0tbLblQqSKTvTyFJePm0KDqpN1i9GSWXhBkaoiqDDenGFAg21M7ZlN46La5YWQy5fxx rVAnokrdpIWWx25HhyvDw0UILDP0mXxjHnnq3zpgiSclOkRVqNVj5LPjRr55uLZbvDM3 OIn/0boTNss/dJmMxOIAIFPqSz9fpgOW1oQobiXz+rhJW9AmsfOlnHVZrdk97o3EH68W KfZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=rSj5FyPyCz0V20bA8w3iGLLMGYT6Ukt8x3qbY2ASWtw=; b=cQ+ypFve/txcWtPV+5uo7sX3kMfHTakOEY4xHtXjILAtlFJHp5UYqiCAnjYcKeGLye xHYHXC+ahy1xwxdHHvThoFbkgt5fLr1msXv27w11wUPTkdijAon3qUlyGfU66Jwh7CYT UfW9S0ehnfhPr7MJ4mN5wD23jRO88SXNyS9P2bnVipSFgEECPvVsOpt/d1AmWXsg2sgB Y+FtWSWrIxsFIEi3+N61/rPpTIS2RIIZnosk10cyzmnPlTcg4SCn0XqjUa0oFLrCM5Mq pOjTslZ9Tu6sxWIXBqTdqGSU/q9pD7wfAbdp5yBJv3EyXfTTyRY3sZF/wiaRegRNeIPF InZQ== X-Gm-Message-State: ACrzQf08VkUo4foCXOIR0+/X3+B3+bnUzlLb8AmLgIXPcn5WImDUWham P5BV9V0eIGbIVGesAC9fGvs= X-Google-Smtp-Source: AMsMyM4sr9P7ENE2rFtYM5LGN1LlXwhJ6Fv1W7HGoek4faQzdRVjPooMCyA6/fzAvUPCPtu3F4hzNQ== X-Received: by 2002:a17:90b:350c:b0:213:2552:21cb with SMTP id ls12-20020a17090b350c00b00213255221cbmr9904938pjb.94.1666721440176; Tue, 25 Oct 2022 11:10:40 -0700 (PDT) Received: from ?IPV6:2601:681:5a00:f790:4f89:843a:652b:fea4? ([2601:681:5a00:f790:4f89:843a:652b:fea4]) by smtp.gmail.com with ESMTPSA id b6-20020a170903228600b00174f7d10a03sm1512364plh.86.2022.10.25.11.10.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Oct 2022 11:10:39 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------ioP6D3D0NOXQ8YPofaYEFQUg" Message-ID: Date: Tue, 25 Oct 2022 12:10:38 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: please give me select sqls examples to distinct these! Content-Language: en-CA To: "David G. Johnston" Cc: jacktby@gmail.com, pgsql-general References: <202210252154573516405@gmail.com> <8E137936-5D93-49FF-93A3-EB4E97D3416C@gmail.com> <9743c2b4-86b9-944d-ca48-6fa73439d70b@gmail.com> From: Rob Sargent In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------ioP6D3D0NOXQ8YPofaYEFQUg Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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. --------------ioP6D3D0NOXQ8YPofaYEFQUg Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 10/25/22 09:58, David G. Johnston wrote:
On Tue, Oct 25, 2022 at 8:56 AM Rob Sargent <robjsargent@gmail.com> 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.johnston@gmail.com> wrote:
On Tue, Oct 25, 2022 at 7:06 AM Rob Sargent <robjsargent@gmail.com> 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.<criteria> = b.<criteria>
to be a functional equivalent of INTERSECT?

SELECT DISTINCT a.* 

David J.
Yeah, sorry.  Meant to distinguish to two "table" defs in some way.
--------------ioP6D3D0NOXQ8YPofaYEFQUg--