Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxVdj-0006zL-Nf for pgsql-bugs@arkaria.postgresql.org; Thu, 28 Sep 2017 10:01:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dxVdj-0005h5-AK for pgsql-bugs@arkaria.postgresql.org; Thu, 28 Sep 2017 10:01:55 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dxVdi-0005gv-Sa for pgsql-bugs@postgresql.org; Thu, 28 Sep 2017 10:01:55 +0000 Received: from smtp1-g21.free.fr ([2a01:e0c:1:1599::10]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dxVdb-0003qz-1Q for pgsql-bugs@postgresql.org; Thu, 28 Sep 2017 10:01:53 +0000 Received: from zimbra48-e8.priv.proxad.net (unknown [172.20.243.198]) by smtp1-g21.free.fr (Postfix) with ESMTP id E522FB00598; Thu, 28 Sep 2017 12:01:43 +0200 (CEST) Date: Thu, 28 Sep 2017 06:01:43 -0400 (EDT) From: jeanpierre.carayol@free.fr To: Tomas Vondra Cc: =?utf-8?B?6Zmz5LiW5rOT?= , pgsql-bugs@postgresql.org Message-ID: <783812923.668562497.1506592903818.JavaMail.root@zimbra48-e8.priv.proxad.net> In-Reply-To: <8543f288-4988-4f1b-0c65-aa3c6acff61a@2ndquadrant.com> Subject: Re: Something strang on "left join" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_668562496_2031477671.1506592903817" X-Originating-IP: [78.226.153.153] X-Mailer: Zimbra 7.2.0-GA2598 (ZimbraWebClient - FF3.0 (Linux)/7.2.0-GA2598) X-Authenticated-User: jeanpierre.carayol@free.fr List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org ------=_Part_668562496_2031477671.1506592903817 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I also suspect the ID columns values for lines identified by CUST-NO.=20 Sorry to ask an additionnal question here. There is a useful Oracle functio= n dump() to check the internal field value. Is there anything similar with = PostgreSQL ?=20 Many thanks for your help.=20 Best Regards,=20 Jean-Pierre=20 ----- Mail original ----- De: "Tomas Vondra" =20 =C3=80: "=E9=99=B3=E4=B8=96=E6=B3=93" , pgsql-bug= s@postgresql.org=20 Envoy=C3=A9: Jeudi 28 Septembre 2017 11:14:11=20 Objet: Re: [BUGS] Something strang on "left join"=20 On 09/28/2017 08:17 AM, =E9=99=B3=E4=B8=96=E6=B3=93 wrote:=20 > Hi,=20 >=20 >=20 >=20 > My pgsql version is 9.6, and I got something wrong result while=20 > using left join.=20 >=20 >=20 >=20 > We used =E2=80=9Cleft join=E2=80=9D to join t1 and t2, the result of the = first=20 > row was wrong ,here is the LEFT JOIN result.=20 >=20 >=20 >=20 > 1. select * from cicifcif=20 >=20 > 2. select * from eccifidi=20 >=20 > 3. select * from cicifcif t1 left join eccifidi t2 on=20 > t1."CI-CUST-NO" =3D t2."EC-CUST-NO" ORDER BY T1."CI-CUST-NO"=20 >=20 >=20 >=20 > THE LEFT JOIN RESULT OF THE FIRST ROW , COLUMNS OF eccifidi SHOULD BE=20 > =E2=80=9C222=E2=80=9D,=E2=80=9DN=E2=80=9D,=E2=80=9DY=E2=80=9D=E2=80=A6.= =20 >=20 Chances are some of the ID columns contain spaces or some other=20 whitespace characters. Try length() on them:=20 SELECT length("CI-CUST-NO") FROM ...=20 SELECT length("EC-CUST-NO") FROM ...=20 regards=20 --=20 Tomas Vondra http://www.2ndQuadrant.com=20 PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services=20 --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)=20 To make changes to your subscription:=20 http://www.postgresql.org/mailpref/pgsql-bugs=20 ------=_Part_668562496_2031477671.1506592903817 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable <= div style=3D'font-family: arial,helvetica,sans-serif; font-size: 12pt; colo= r: #000000'>I also suspect the ID columns values for lines identified by CU= ST-NO.

Sorry to ask an additionnal question here. There is a useful = Oracle function dump() to check the internal field = value. Is there anything similar with PostgreSQL ?

Many thanks for = your help.

Best Regards,
Jean-Pierre


De: "Tom= as Vondra" <tomas.vondra@2ndquadrant.com>
=C3=80: "=E9=99= =B3=E4=B8=96=E6=B3=93" <adam_chen@bankpro.com.tw>, pgsql-bugs@postgre= sql.org
Envoy=C3=A9: Jeudi 28 Septembre 2017 11:14:11
Objet= : Re: [BUGS] Something strang on "left join"



On 09/28/20= 17 08:17 AM, =E9=99=B3=E4=B8=96=E6=B3=93 wrote:
> Hi,
>
>= ;  
>
>         My pgs= ql version is 9.6, and I got something wrong result while
> using lef= t join.
>
>        
>=
>         We used =E2=80=9Cleft = join=E2=80=9D to join t1 and t2, the result of the first
> row was wr= ong ,here is the LEFT JOIN result.  
>
>  
> <= br>> 1.     select * from cicifcif
>
> = 2.     select * from eccifidi
>
> 3. =     select * from cicifcif t1 left join eccifidi t2 on
&g= t; t1."CI-CUST-NO" =3D t2."EC-CUST-NO" ORDER BY T1."CI-CUST-NO"
> >  
>
>   THE LEFT JOIN RESULT OF THE FIRST ROW = , COLUMNS OF eccifidi SHOULD BE
> =E2=80=9C222=E2=80=9D,=E2=80=9DN=E2= =80=9D,=E2=80=9DY=E2=80=9D=E2=80=A6.
>

Chances are some of th= e ID columns contain spaces or some other
whitespace characters. Try len= gth() on them:

    SELECT length("CI-CUST-NO") FROM .= ..
    SELECT length("EC-CUST-NO") FROM ...

regard= s

--
Tomas Vondra             &nbs= p;    http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 = Support, Remote DBA, Training & Services


--
Sent via pgs= ql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your= subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
------=_Part_668562496_2031477671.1506592903817--