From: | Michael Nolan <htfoot(at)gmail(dot)com> |
---|---|
To: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
Cc: | "pgml(at)gmx(dot)de" <pgml(at)gmx(dot)de>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: SQL Question about like |
Date: | 2020-08-10 17:44:28 |
Message-ID: | CAOzAquL2foLbjr0zMr83N36ccy5mzD62ghaj=c1BBPfJb3GEoQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I usually use something like trim(field) like 'pattern'. Eliminates the
need for the wildcard at the end. I find I use the ~ operator more than
'like' though.
--
Mike Nolan
On Mon, Aug 10, 2020 at 12:24 PM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:
> 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(dot)klaver(at)aklaver(dot)com
>
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Nolan | 2020-08-10 17:49:54 | Re: SQL Question about like |
Previous Message | Adam Brusselback | 2020-08-10 17:38:02 | Re: UUID or auto-increment |