pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
text & char(32)
4+ messages / 4 participants
[nested] [flat]

* text & char(32)
@ 2000-09-19 07:46  Vladimir V. Zolotych <gsmith@eurocom.od.ua>
  0 siblings, 2 replies; 4+ messages in thread

From: Vladimir V. Zolotych @ 2000-09-19 07:46 UTC (permalink / raw)
  To: pgsql-admin

  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)
So the operator '=' doesn't work as I expected.
Any help will be appreciated.

-- 
Best regards,
 Vladimir                          mailto:gsmith@eurocom.od.ua





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: text & char(32)
@ 2000-09-19 09:16  Karel Zak <zakkr@zf.jcu.cz>
  parent: Vladimir V. Zolotych <gsmith@eurocom.od.ua>
  1 sibling, 0 replies; 4+ messages in thread

From: Karel Zak @ 2000-09-19 09:16 UTC (permalink / raw)
  To: Vladimir V. Zolotych <gsmith@eurocom.od.ua>; +Cc: 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




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: text & char(32)
@ 2000-09-19 14:01  bangh <banghe@baileylink.net>
  parent: Herbert Ambos <herbert@hindang.msuiit.edu.ph>
  0 siblings, 0 replies; 4+ messages in thread

From: bangh @ 2000-09-19 14:01 UTC (permalink / raw)
  To: Vladimir V. Zolotych <gsmith@eurocom.od.ua>; +Cc: pgsql-admin

If your define your table using varchar(32), instead of char(32), your
query will work fine.


--
banghe

Herbert Ambos wrote:

> 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)
> > So the operator '=' doesn't work as I expected.
> > Any help will be appreciated.
> >
> >
>
> try
>
>         select * from foo where tt=trim(cc);
>
> herbert




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: text & char(32)
@ 2000-09-19 17:17  Herbert Ambos <herbert@hindang.msuiit.edu.ph>
  parent: Vladimir V. Zolotych <gsmith@eurocom.od.ua>
  1 sibling, 1 reply; 4+ messages in thread

From: Herbert Ambos @ 2000-09-19 17:17 UTC (permalink / raw)
  To: Vladimir V. Zolotych <gsmith@eurocom.od.ua>; +Cc: 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)
> So the operator '=' doesn't work as I expected.
> Any help will be appreciated.
> 
> 

try

	select * from foo where tt=trim(cc);



herbert




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2000-09-19 17:17 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-09-19 07:46 text & char(32) Vladimir V. Zolotych <gsmith@eurocom.od.ua>
2000-09-19 09:16 ` Karel Zak <zakkr@zf.jcu.cz>
2000-09-19 17:17 ` Herbert Ambos <herbert@hindang.msuiit.edu.ph>
2000-09-19 14:01   ` bangh <banghe@baileylink.net>

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