Operation eq with varchar

Started by Nonameover 24 years ago4 messagesgeneral
Jump to latest
#1Noname
t.ngockhoi@bpf.vnu.com

HI ALL,

I don't no why i can't compare varchar with string const :

CREATE TABLE XXX (
id integer,
stvarchar varchar
) ;

SELECT * FROM XXX WHERE stvarchar = 'somestring' ;

I can only use like operator :

SELECT * FROM XXX WHERE stvarchar like 'somestring%' ;

Any body know why ?

I have the 7.1.3 verion in redhat 7.2

Best Regards,
Ngoc-Khoi TO.

#2Martijn van Oosterhout
kleptog@svana.org
In reply to: Noname (#1)
Re: Operation eq with varchar

On Thu, Dec 20, 2001 at 09:38:15AM +0100, t.ngockhoi@bpf.vnu.com wrote:

HI ALL,

I don't no why i can't compare varchar with string const :

SELECT * FROM XXX WHERE stvarchar = 'somestring' ;

Does this work? (Untested)

SELECT * FROM XXX WHERE stvarchar = 'somestring'::varchar ;

HTH,
--
Martijn van Oosterhout <kleptog@svana.org>
http://svana.org/kleptog/

Show quoted text

Terrorists can only take my life. Only my government can take my freedom.

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Noname (#1)
Re: Operation eq with varchar

Perhaps you are forgetting to allow for trailing blanks in the stored
data? Those are significant if you're using varchar.

regards, tom lane

#4SHELTON,MICHAEL (Non-HP-Boise,ex1)
michael_shelton@non.hp.com
In reply to: Tom Lane (#3)
Re: Operation eq with varchar

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Thursday, December 20, 2001 8:02 AM
To: t.ngockhoi@bpf.vnu.com
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Operation eq with varchar

Perhaps you are forgetting to allow for trailing blanks in the stored
data? Those are significant if you're using varchar.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org