agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Christophe Pettus <xof@thebuild.com>
To: Tchouante, Merlin <mtchouan@umaryland.edu>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: Like Command returning wrong result set
Date: Thu, 5 Aug 2021 07:05:13 -0700
Message-ID: <595A741D-8D12-4FB8-8794-28D3319EE2CD@thebuild.com> (raw)
In-Reply-To: <CH0PR12MB5105EEAFE0AF3085B4F1095FD2F29@CH0PR12MB5105.namprd12.prod.outlook.com>
References: <CH0PR12MB5105EEAFE0AF3085B4F1095FD2F29@CH0PR12MB5105.namprd12.prod.outlook.com>
> On Aug 5, 2021, at 07:00, Tchouante, Merlin <mtchouan@umaryland.edu> wrote:
>
> Hello group,
>
> I’m writing a script and a bit confused on the results with the like command.
>
> gm.title like 'CP_%'
>
> The above command gives me records with titles like CP_40, CP_2, CP_23, etc.
>
> gm.title like '%_CT'
Somewhat confusingly, '_' is the single-character wildcard for SQL's LIKE operation:
xof=# SELECT 'A' LIKE '_';
?column?
----------
t
(1 row)
You can escape it to search for it literally:
xof=# SELECT '_' LIKE '\_';
?column?
----------
t
(1 row)
xof=# SELECT 'A' LIKE '\_';
?column?
----------
f
(1 row)
view thread (4+ messages) latest in thread
Message-ID: <595A741D-8D12-4FB8-8794-28D3319EE2CD@thebuild.com>
Permalink: ../595A741D-8D12-4FB8-8794-28D3319EE2CD@thebuild.com/
Also on: postgresql.org/message-id/595A741D-8D12-4FB8-8794-28D3319EE2CD@thebuild.com
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: xof@thebuild.com, mtchouan@umaryland.edu
Subject: Re: Like Command returning wrong result set
In-Reply-To: <595A741D-8D12-4FB8-8794-28D3319EE2CD@thebuild.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox