Search Postgresql Archives

CHAR LIKE VARCHAR

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

I came across following difference
between "LIKE" and "=" regarding
CHARs and VARCHARs

create table aa(f5 char(5), fv varchar(5));
insert into aa values('str1', 'str1');
select count(*) from aa where f5 = fv;
> 1
select count(*) from aa where f5 like fv;
> 0

I understand trailing spaces in CHAR are not
significant though I expect DBMS shows
consistent (and, ideally, clearly documented)
behavior. 

>From my point of view in example above 
it would be nice to have the same result 
for both queries regardless it is 0 or 1.

Of course, I may be wrong. Is there a clear 
concept behind the difference between "LIKE"
and "="?

Thanks.

-- 
Best regards
Ilja Golshtein

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
      message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux