| From: | Karel Zak <zakkr(at)zf(dot)jcu(dot)cz> | 
|---|---|
| To: | "Vladimir V(dot) Zolotych" <gsmith(at)eurocom(dot)od(dot)ua> | 
| Cc: | pgsql-admin(at)postgresql(dot)org | 
| Subject: | Re: text & char(32) | 
| Date: | 2000-09-19 09:16:39 | 
| Message-ID: | Pine.LNX.3.96.1000919111204.3444B-100000@ara.zf.jcu.cz | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-admin | 
On Tue, 19 Sep 2000, Vladimir V. Zolotych wrote:
>   Hi all,
> Can you help me a bit ?
> The question is: how can I compare TEXT and CHAR(32) types ?
> More detailed description:
>   my=> create table foo (tt text, cc char(32));
> 
>   CREATE
>   my=> insert into foo values ('aa', 'ab');
> 
>   INSERT 27476810 1
>   my=> insert into foo values ('aa', 'aa');
> 
>   INSERT 27476811 1
>   my=> select * from foo where tt=cc;
> 
>   tt|cc
>   --+--
>   (0 rows)
Because you not compare 'aa' and 'aa' but
	'aa' and 'aa                    '
                  ^^^^^^^^^^^^^^^^^^^^^^
			   32 chars
try:
 test=# select * from foo where tt::char = cc;
 tt |                cc
----+----------------------------------
 aa | aa
(1 row)
 Better is use varchar(32) for 'cc' if you want run this (tt=cc) query 
often.
  
				Karel
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jan-Hendrik Benter | 2000-09-19 13:20:10 | DENY database access to others than owner | 
| Previous Message | Vladimir V. Zolotych | 2000-09-19 07:46:37 | text & char(32) |