Skip site navigation (1) Skip section navigation (2)

TR: Like and =

From: "Nicolas JOUANIN" <n(dot)jouanin(at)regie-france(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: TR: Like and =
Date: 2003-06-23 16:29:51
Message-ID: CEEJJOCKHCPFNIOMMIDFMEGGCHAA.n.jouanin@regie-france.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-sql
Hi,

  I've got a table , pdi, with a field pro_id defined as char(25). One fied
og this table contains the string '1006666058' plus spaces to fill the 25
length (ie pro_id = '1006666058               ').
  When I run:
   select * from pdi where pdi = '1006666058'  the row is returned.
  When I run:
   select * from pdi where pdi like '1006666058'  the row is NOT returned.

select length(pro_id) where pdi = '1006666058' returns:
length
-----------
25

2 Row(s) affected

1) In PostgreSQL documentation, it's said that without % wildcards like
operates the same as = , it seems not.
2) Why does the = operator return the row ? it shouldn't because of the
trailing spaces.
3) The row was inserted from the COPY command:
COPY pdi FROM STDIN NULL as '' DELIMITER as '|';
VOL|1006666058|0|PART||PART
\.
Why does my field contain trailing spaces ?

Regards and thanks again for your useful help.


PS:
create table pdi
  (
    pmf_id char(4) not null ,
    pro_id char(25) not null ,
    lng_id char(3) not null ,
    pdi_desc char(50) not null ,
    pdi_instr text,
    pdi_matchdesc char(50),
    CONSTRAINT pk_pdi PRIMARY KEY (pro_id,pmf_id,lng_id)
  );

Nicolas.

---------------------------------------------------------------
Nicolas JOUANIN - SA REGIE FRANCE
Village Informatique BP 3002
17030 La Rochelle CEDEX
Tel: 05 46 44 75 76
Fax: 05 46 45 34 17
email: n(dot)jouanin(at)regie-france(dot)com
Web : www.regie-france.com
---------------------------------------------------------------



Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2003-06-23 16:37:51
Subject: Re: Two Phase Commit WAS: Re: Two weeks to feature freeze
Previous:From: Hans-Jürgen SchönigDate: 2003-06-23 16:24:32
Subject: dblink for Oracle - question ...

pgsql-sql by date

Next:From: Chad ThompsonDate: 2003-06-23 16:44:46
Subject: Re: Urgent Help : Use of return from function/procedure.
Previous:From: L.V.BoldarevaDate: 2003-06-23 15:26:06
Subject: Re: CREATE table1 FROM table2

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group