Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxUuU-0003se-JP for pgsql-bugs@arkaria.postgresql.org; Thu, 28 Sep 2017 09:15:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dxUuU-0005e5-1Y for pgsql-bugs@arkaria.postgresql.org; Thu, 28 Sep 2017 09:15:10 +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 1dxUtl-0004MB-2e for pgsql-bugs@postgresql.org; Thu, 28 Sep 2017 09:14:25 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dxUtd-0002o3-8C for pgsql-bugs@postgresql.org; Thu, 28 Sep 2017 09:14:23 +0000 Received: by mail-wm0-x22d.google.com with SMTP id r74so860762wme.4 for ; Thu, 28 Sep 2017 02:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=Mi4Zk6M5PWzdtAYiOogMtRnFWw/e7+2020TuPMQh8/A=; b=qNKa/jl5i6egPVcr5TKw+XuCqR8RcedMBwilmtSIqHhoWMMTzCWavbxeLKyRkK0Jlw aXu47vS+rFONrylZWrfMxHBXFiRU8V+hmNKIeDg2UmSZszppS6qcor47X57vetqC3h+y owk8KzF7x1IXiGpj8AS4FJ5Un2jFlVbpUSQ5vN/RlvEHqjf4gHTv2dbmsjuBWmPyC+DT 7sd0W+X30ClOxeUOrD8vViO7DgmrcGSLvQjDsK51Ulkn7rWyA2sGJSPTnXbFcnmWzuIT c1pWrYlIZAFSBC1AwjJKI+t4NyUKbSg+nSbPqBoTdzlmMUwtYd5JIfEj7QcHcFzfOXkW wPGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Mi4Zk6M5PWzdtAYiOogMtRnFWw/e7+2020TuPMQh8/A=; b=i6a6xxlB9QSc/Lc7Tn/mzQePSpLl7xA/uifabq42THotx3tnfD4DyQSvoFw8G3w3Gp xmqbhUJhMYlhBfUeEHD1O+Fx4iFct9GvoD7ln7+3JDPn4aU2QcvRLegqfnPbvBPBMlat eLKWL6w2b8tBMbscpEH5GocBuRB0qGEttD/aOIK/7xWaWywa1YU23v34cmObzQxPqmks Hy2V9Ogu11SYIgTjsh+nQEX59exRIwB7d/0diCMdQFGE3je8nbvpQNftBtkMHv0+Xz41 6bl1zWFUl5Q04q/4XyBrH/JUSThh8UZ7L6HTpI6zmrCVeW/WZMcZOkWNE7LG5zIn2Kp7 ChoQ== X-Gm-Message-State: AHPjjUhLHBLYW7LBEbFXcscmC3sQjcwUGEzPA8wKwSBzf75w2TABArdE 9oYF38HP6FWsm7jdu7vpr/M6e3ZxbbcZgL/y8WuWktifXdqfyxIi0L9/ZnJSDau400Ktnbxhir3 w9x3vBqWnEqD2V5I/7rykkgEgVtrPkk+Me99bDwelD7dPcunDVHGivM3BrrqterJTsnuxnd8bLy lwlka3 X-Google-Smtp-Source: AOwi7QCH7RtEJ73JoERVm+EgTJaDfFEJzLsYBFXnGgdy3NBbyiwXBiOdqmYturPYfpHK6rAz7YU20g== X-Received: by 10.80.164.171 with SMTP id w40mr4977412edb.168.1506590054762; Thu, 28 Sep 2017 02:14:14 -0700 (PDT) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id g2sm958229eda.23.2017.09.28.02.14.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 02:14:14 -0700 (PDT) Subject: Re: Something strang on "left join" To: =?UTF-8?B?6Zmz5LiW5rOT?= , "pgsql-bugs@postgresql.org" References: <0f8812cf2e764fc586229bab1b10ea79@SRMAIL.bankpro.com.tw> From: Tomas Vondra Message-ID: <8543f288-4988-4f1b-0c65-aa3c6acff61a@2ndquadrant.com> Date: Thu, 28 Sep 2017 11:14:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <0f8812cf2e764fc586229bab1b10ea79@SRMAIL.bankpro.com.tw> Content-Type: text/plain; charset=UTF-8 Content-Language: en-US Content-Transfer-Encoding: 8bit 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 On 09/28/2017 08:17 AM, 陳世泓 wrote: > Hi, > >   > >         My pgsql version is 9.6, and I got something wrong result while > using left join. > >         > >         We used “left join” to join t1 and t2, the result of the first > row was wrong ,here is the LEFT JOIN result.   > >   > > 1.     select * from cicifcif > > 2.     select * from eccifidi > > 3.     select * from cicifcif t1 left join eccifidi t2 on > t1."CI-CUST-NO" = t2."EC-CUST-NO" ORDER BY T1."CI-CUST-NO" > >   > >   THE LEFT JOIN RESULT OF THE FIRST ROW , COLUMNS OF eccifidi SHOULD BE > “222”,”N”,”Y”…. > Chances are some of the ID columns contain spaces or some other whitespace characters. Try length() on them: SELECT length("CI-CUST-NO") FROM ... SELECT length("EC-CUST-NO") FROM ... regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs