Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jBeZi-0002tk-WB for pgsql-general@arkaria.postgresql.org; Tue, 10 Mar 2020 13:05:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jBeZh-0005jj-JI for pgsql-general@arkaria.postgresql.org; Tue, 10 Mar 2020 13:05:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jBeZh-0005jc-6O for pgsql-general@lists.postgresql.org; Tue, 10 Mar 2020 13:05:33 +0000 Received: from sonic305-20.consmr.mail.sg3.yahoo.com ([106.10.241.83]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jBeZe-00080m-BM for pgsql-general@lists.postgresql.org; Tue, 10 Mar 2020 13:05:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1583845525; bh=E2puEzgFb+8Lh7ICx63J5uIBZ59YOZelYvRZe/5pXPI=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=ftz79X4PFHBmWbhF0GLRtrlWL0xCNLwPKPVhk1oI0zm9WUmMk3keurvlxDrSkRs7JwAgMy2YiVryFonR5WK79Hyw860dJTW82zEGdGmuCxUgJnvx4uOPtniCEAfFrXHEoelpYCjHVm68VUQbtSxwWPnOuMLVToDq4vGbLmv0wSWBxPAOxpzUYk8sfUmNb+i9y9AdaUOda4mEm6I6EwXMgKNkXWa+YzusFe9wUM1nNY/6JxBAa0bjT8JprtalbtKCF2//ErJjlg6wYr9/X4Q2b+1dj9Itzeebep50Q8B3ZBHY+j6jV83m+RotM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3iYn1SaHalbG2VHhOzzT5k E0Lf1XvV9DMCAG9bYzuwex3Vdh96rexcxr5Lg3QRwYKr4UhJYjTOoRXM_ALXVqjdjho29Q92FZJW Gki_Zjvluyd921OQjymR0zNep.il8dzREjmCxaP9Wh9lJcl4_Yb5Dl4ABBRcdVjArc7WMKaSWBNV fEbk7Ya3V1lVHi3xsVlJDKjWH.VNeiOP1GYpLjnk3ye.UBc3YuZo0IEe.C5Njvg1vJ1mdBZPE9JZ Uek7aST0SWvuBc2mHXdCQUV56V0N38HIe2hjenRIH2TtKKRHPQCVhqxZsfDisJyG4hO9nZGpnoW_ zb0rDx46KT9u8XUySBYERAgIiXSA2HFcsGt1r6SDLCqyFiz9Em6y1c.uM_ngmDOH.cWizO8ucjVh _19EZejqC0q5j Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.sg3.yahoo.com with HTTP; Tue, 10 Mar 2020 13:05:25 +0000 Received: by smtp405.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID cb28174fb8c44a5a843c2d407e333a69; Tue, 10 Mar 2020 13:05:23 +0000 (UTC) X-YMail-OSG: a6mXdPMVM1lk2h7oGFvCHL2R9mEIiV0RkD2fuZcXadEHE2C1TbS7WLdddGApyc7 86OBADb.dFBL2vs4xc6XT0jRziM3ohdjgbBMMhNrFKO8KvFP1EyHo6_0tycG_XLzPk9VUN2TO1Pa 3Iyu4WcWXRzSP.8guaeFIPOLesy0bcqyBZEJdkGibhesUzTzhSjehFRyzzYrn6u3L.zMn7kjj.vx IhTIwePZLZ_mLFWazhmCRO7C0vfes53sgCpR_LOw44cWd0oYBreg_HciCJ.r2bMLN.2gTBNd.btC wDAgOlHKN8m7nS9NjEwe_oaChfZAosb3HkB.sm4mnS5MBS8VbC5oLCJsl_iARWTIY_JdkQFS.rW1 rGnIJiMpjGRnYzi_jqa8Glis4HzS6090PbnqmlpOkVFTVUfi22n_dwPhB_oUuaT96TtBwTZZyk8l ZjG_JZNXMA_D4hw388UAGDRzx_fG18XnVZPBQZIS7eILrtWS3MSWJkIZgWtfUHRan0jgOuyEM5iU m095jQL4ZDb9xNKaCkis7fpIf0tmvXH_J8wxFtuQwd39uK21BBW2NDBdPh.guzGCxax8Ee9Ipo.i sFtXgDoSXmDA7Lvr10W52xcBnZ2Nk9SihMCTt8Ji44eC5kONCsNZE6UrIjQWTZVMEikKt7T0Uwdi jPXO1WArwJXxPKYmeB3LPjRXgjKn0XPTqUCCwyjE12f5NGe6hmRE_bCikUFFD724ujbjDboLAX7o 4NbfxjwXLIIG45my4YJQqF8kdqQTCsLoL_S0CnVs1fGBOzHMIXTZDazaNRJL8aojM212ktiOSgoQ QrCdRVapvBiZQuG97durNfWBj4GXuBpcc4CyfT1GUU_EMdlK.Gge.NBLGT8kI_0yw3Fmzst3PM4a Vf6Q2ZehCTT_I1fahAGQ1ErEJxHegpIfyNbqt1SGBe3Pir6Igog00kaprDmd8ajtAN6IDmWCvz02 EAni4LeWANqcIpotLwPVI6qfsMsBQUs5zs9z3yQiGB8YINdZ9H4rAWQ2YGtbwUMRuXE.61PhFp3T APKjPKvt7UU2vahLI5mgZhcgNmAvU6_uITiESyvNNGqXOlZToCZjhNi8yVYW0GrvoqE7WGTzBaFH lEv0Wb4QGY2UhUaa_5.I7B2GQkl5DoD2PGZtbf4Kk30fWhXxpNWJ3aewuNmub53n3.2yAo12UFQM 06eqKmeW8yMv.sNpWkNWXiIzUsoKfHDCwjWtzpZOZRTaxsPxgZpvOyWcvReL9Sjjucmw7YXed8SM r8gX8zBRjl89MdWk6r1eDJ07.9UnfJReePZSJyHshENBap3WucNnczDLS8VSbbv0LFBezAuOUL5p vml0qM4ixXAZQH6ea Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.gq1.yahoo.com with HTTP; Tue, 10 Mar 2020 13:05:22 +0000 Date: Tue, 10 Mar 2020 13:05:20 +0000 (UTC) From: "sivapostgres@yahoo.com" Reply-To: "sivapostgres@yahoo.com" To: "pgsql-generallists.postgresql.org" Message-ID: <1984187071.3080276.1583845520147@mail.yahoo.com> In-Reply-To: References: <1482349013.1084585.1583844541651.ref@mail.yahoo.com> <1482349013.1084585.1583844541651@mail.yahoo.com> Subject: Re: select * from test where name like 'co_%' MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_3080275_1537903171.1583845520146" X-Mailer: WebService/1.1.15342 YMailNorrin Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36 Content-Length: 4418 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_3080275_1537903171.1583845520146 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks.=C2=A0 Got it. On Tuesday, 10 March, 2020, 06:30:27 pm IST, Paul Foerster wrote: =20 =20 Hi, an underscore matches a single character, any character. You'd have to escape it and tell the query what the escape character is if you want it to be treated as a standard character: db=3D# create table t(t text); CREATE TABLE db=3D# insert into t(t) values ('fox'), ('fo_'), ('fo_x'); INSERT 0 3 db=3D# select * from t; =C2=A0 t ------ fox fo_ fo_x (3 rows) db=3D# select * from t where t like 'fo_%'; =C2=A0 t ------ fox fo_ fo_x (3 rows) db=3D# select * from t where t like 'fo\_%' escape '\'; =C2=A0 t ------ fo_ fo_x (2 rows) Cheers, Paul On Tue, Mar 10, 2020 at 1:49 PM sivapostgres@yahoo.com wrote: > > Hello, > > What returns when I run a query like this; > > Select * from test where name like 'co_%'; > > I expect anything that starts with 'co_' and NOT 'co' only.=C2=A0 Am I ri= ght?=C2=A0 But I get every names that starts with 'co'. Why ? > > Happiness Always > BKR Sivaprakash > =20 ------=_Part_3080275_1537903171.1583845520146 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks.  Got it.
<= div>
=20
=20
On Tuesday, 10 March, 2020, 06:30:27 pm IST, Paul Foers= ter <paul.foerster@gmail.com> wrote:


Hi,

an underscore matches a single character, any character. You'd have to<= br clear=3D"none">escape it and tell the query what the escape character is= if you want
it to be treated as a standard character:
db=3D# create table t(t text);
CREATE TABLE
db=3D# insert into t(t) values ('f= ox'), ('fo_'), ('fo_x');
INSERT 0 3
db= =3D# select * from t;
  t
------ fox
fo_
fo_x
(3 rows)

db=3D# select * f= rom t where t like 'fo_%';
  t
---= ---
fox
fo_
fo_x(3 rows)

db=3D# selec= t * from t where t like 'fo\_%' escape '\';
  t
------
fo_
fo_x
(2 rows)

Cheers,
Paul

On Tue, Mar 10, 2020 at 1:49 PM sivapostgres@yahoo.com
<sivapostgres@yahoo.com> wrote:
>
> Hello,
>
> What retur= ns when I run a query like this;
>
&= gt; Select * from test where name like 'co_%';
>
> I expect anything that starts with 'co_' and NOT 'co' onl= y.  Am I right?  But I get every names that starts with 'co'. Why= ?
>
> Happiness Always
> BKR Sivaprakash
>

------=_Part_3080275_1537903171.1583845520146--