pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: 陳世泓 <adam_chen@bankpro.com.tw>
To: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: Something strang on "left join"
Date: Thu, 28 Sep 2017 11:14:11 +0200
Message-ID: <8543f288-4988-4f1b-0c65-aa3c6acff61a@2ndquadrant.com> (raw)
In-Reply-To: <0f8812cf2e764fc586229bab1b10ea79@SRMAIL.bankpro.com.tw>
References: <0f8812cf2e764fc586229bab1b10ea79@SRMAIL.bankpro.com.tw>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>



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



view thread (5+ messages)  latest in thread

Message-ID: <8543f288-4988-4f1b-0c65-aa3c6acff61a@2ndquadrant.com>
Permalink:  ../8543f288-4988-4f1b-0c65-aa3c6acff61a@2ndquadrant.com/
Also on:    postgresql.org/message-id/8543f288-4988-4f1b-0c65-aa3c6acff61a@2ndquadrant.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tomas.vondra@2ndquadrant.com, adam_chen@bankpro.com.tw
  Subject: Re: Something strang on "left join"
  In-Reply-To: <8543f288-4988-4f1b-0c65-aa3c6acff61a@2ndquadrant.com>
  References: <0f8812cf2e764fc586229bab1b10ea79@SRMAIL.bankpro.com.tw> <8543f288-4988-4f1b-0c65-aa3c6acff61a@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox