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

Comparison of Strings

From: Mike Schulte <schulte(at)cs(dot)umsl(dot)edu>
To: pgsql-bugs(at)postgresql(dot)org
Cc: schulte(at)arch(dot)cs(dot)umsl(dot)edu, dgayou(at)cs(dot)umsl(dot)edu
Subject: Comparison of Strings
Date: 2000-11-20 15:48:42
Message-ID: 3A1947DA.D9359C1D@cs.umsl.edu (view raw or flat)
Thread:
Lists: pgsql-bugs
I am running
      PostgreSQL 7.0.2 on sparc-sun-solaris2.8, compiled by gcc 2.95.2

I have a database table whose contents are

cs302=# select * from author;
     isbn     |         author
--------------+-------------------------
 '1565921941' | 'Meyer, Jon'
 '1565921941' | 'Downing, Troy'
 '0201100886' | 'Aho, Alfred V.'
 '0201100886' | 'Sethi, Ravi'
 '0201100886' | 'Ullman, Jeffrey D.'
 '0878518096' | 'Maloney, Elbert S.'
 '0870211641' | 'Maloney, Elbert S.'
 '0441865003' | 'Thomson, Amy'
 '0312944446' | 'Vinge, Vernor'
 '0030860784' | 'Hungerford, Thomas W.'
 '0201038099' | 'Knuth, Donald E.'
 '1565920015' | 'Gilly, Daniel'
(12 rows)


If I run the following command, I get  [the string matches the first two
entries in the table]:

cs302=# select * from author where isbn = '1565921941';
 isbn | author
------+--------
(0 rows)


If I change the = to a ~, I get

cs302=# select * from author where isbn ~ '1565921941';
     isbn     |     author
--------------+-----------------
 '1565921941' | 'Meyer, Jon'
 '1565921941' | 'Downing, Troy'
(2 rows)


Is there something about comparison of strings with the = that I don't
see, that makes it different from string matching with the ~?

---
Michael Schulte              Specialist in Computer Science
UM-St. Louis                 schulte(at)cs(dot)umsl(dot)edu
8001 Natural Bridge Road     (314) 516 5239
St. Louis, MO  63121  USA
http://cs.umsl.edu/~schulte



Responses

pgsql-bugs by date

Next:From: DaviS QuiricoDate: 2000-11-20 15:53:15
Subject: Function COPY
Previous:From: Andrea BaldoniDate: 2000-11-20 15:01:25
Subject: Bug report

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