Re: SQL Question about like - Mailing list pgsql-general

From Adrian Klaver
Subject Re: SQL Question about like
Date
Msg-id 2aa71c20-aac8-fc7a-8b4d-0f334de878f1@aklaver.com
Whole thread Raw
In response to Re: SQL Question about like  (Michael Nolan <htfoot@gmail.com>)
Responses Re: SQL Question about like  (Michael Nolan <htfoot@gmail.com>)
List pgsql-general
On 8/10/20 10:01 AM, Michael Nolan wrote:
> The problem is your field is fixed length text, change it to 
> varchar(100) or text and it works without the wildcard at the end.

That assumes values don't get entered  with spaces:

create table lll (text varchar(100));
insert into lll (text) values ('10% - Ersthelfer');
insert into lll (text) values ('10% - Ersthelfer   ');

select * from lll where text like '10% - Ersthelfer';
        text
------------------
  10% - Ersthelfer
(1 row)

select * from lll where text like '10% - Ersthelfer%';
         text
---------------------
  10% - Ersthelfer
  10% - Ersthelfer

I have seen that enough times to default to using wildcard if I am 
really looking for LIKE not =.

> --
> Mike Nolan
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com



pgsql-general by date:

Previous
From: Stephen Frost
Date:
Subject: Re: UUID or auto-increment
Next
From: Adam Brusselback
Date:
Subject: Re: UUID or auto-increment