RE: Like Command returning wrong result set

From: "Tchouante, Merlin" <mtchouan(at)umaryland(dot)edu>
To: Christophe Pettus <xof(at)thebuild(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: RE: Like Command returning wrong result set
Date: 2021-08-05 14:09:41
Message-ID: CH0PR12MB51059533029DE59775E52836D2F29@CH0PR12MB5105.namprd12.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

This worked, thank you so much; I'm still stuck in Oracle mode. Thank you to everyone that responded.

Thanks,
  -- Merlin
 
 
Merlin D. Tchouante, Sr. IT Enterprise Application Developer
Center for Information Technology Services (CITS)
601 West Lombard Street
Baltimore, Maryland 21201-1512
mtchouan(at)umaryland(dot)edu 
410-706-4489 * 410-706-1500 fax

Please send Blackboard questions to the CITS support email address:  DL-CITSBbSupport(at)umaryland(dot)edu
Please send Mediasite questions to the CITS support email address:  DL-CITSMediasiteSupport(at)umaryland(dot)edu

-----Original Message-----
From: Christophe Pettus <xof(at)thebuild(dot)com>
Sent: Thursday, August 5, 2021 10:05 AM
To: Tchouante, Merlin <mtchouan(at)umaryland(dot)edu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Like Command returning wrong result set

CAUTION: This message originated from a non-UMB email system. Hover over any links before clicking and use caution opening attachments.

> On Aug 5, 2021, at 07:00, Tchouante, Merlin <mtchouan(at)umaryland(dot)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)

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tony Shelver 2021-08-05 14:33:36 Re: How to generate the order if you know the next item for each item?
Previous Message Zied Kharrat 2021-08-05 14:08:58 Show table and columns with null value and count