Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k5Aye-0006cJ-82 for pgsql-general@arkaria.postgresql.org; Mon, 10 Aug 2020 16:48:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k5Ayb-0003X8-Ns for pgsql-general@arkaria.postgresql.org; Mon, 10 Aug 2020 16:48:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k5Ayb-0003X1-E6 for pgsql-general@lists.postgresql.org; Mon, 10 Aug 2020 16:48:45 +0000 Received: from mail-oo1-xc31.google.com ([2607:f8b0:4864:20::c31]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k5AyU-0003QI-MA for pgsql-general@lists.postgresql.org; Mon, 10 Aug 2020 16:48:45 +0000 Received: by mail-oo1-xc31.google.com with SMTP id g1so851709oop.11 for ; Mon, 10 Aug 2020 09:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=sO/xv8bycchxfO3BXafVSylmx8JmnHBF9qtTiuwIvQw=; b=NIZO43oYNTSOkkvSkDUUhVrJ/PPBwtcOyvIR8qB3Xnl6n7zweSoeK7dUvo1IxPrrl4 zx3z3Mt8II0aEEPUEZLXDYUJYoUw0D4vSUXt1HmR2fKJDj7bLeSloeBEYVRgS+IWNOT+ Qym6/mUEN/Ww9Q/caVgHIxkFQIp6QCA9tnyttTlQ1kRPQahtCBXoqw8OyXbXuNM0FDPc Zi3maZUJVFrvpQICrpx/oZaudBsMwoXiaBdhlTbWauvUlIb+Hhp8w1/MLb+lipCy8rz1 buP4HZZMsncrQitPq0Hvzmmey+7Pz9Hm0gBdixhj4znjzon5in0jlwz/E54k+HYl380E 1L8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=sO/xv8bycchxfO3BXafVSylmx8JmnHBF9qtTiuwIvQw=; b=mIjx6rpyQQ988ymKNBrYa+qd81ry66wWb+2RjlnCAe580OLQ/XYil/boBzZ57ue8Dx 79uUa11V+bMTLbx6sgSVssyOCPU07LuZkc9ZFU1nBW4DCAIwNxUVIXwwAviKHcG7x8wD 1QqWNyb47jq+MsVOmzb83ehOzwXVCYFly5CbsgL/5BgSA9wTMafvROXuKggLntpq6LKY IgPCnLGTcWhGXnALEERS2B28Hoj2sF0UYcSM3vMyrEvfYE4aM1PMh3zYpODm8aR7eRyH lh1dvOlUu9/gbVJ8UE1auj891skfEkua7dpErLHofYKSCB0pDQRiCaBknuB7w2ZArlSk lE6g== X-Gm-Message-State: AOAM532shnuA1onLN5Bx/CWi7vWoGUeduWI2XSBattnLEP7184ymIpSN jFdUEuNMiRBBMAN5rKa09g43HrpEXCk= X-Google-Smtp-Source: ABdhPJzYHRJ39LsvxiNLpgKy/yc8dcKIB3OHzxpr6zQp1PysY6uxWFjy42C/ktLC6ufELjSk7t/huw== X-Received: by 2002:a4a:8d42:: with SMTP id x2mr1590035ook.76.1597078115831; Mon, 10 Aug 2020 09:48:35 -0700 (PDT) Received: from [192.168.1.10] (ip70-186-126-197.no.no.cox.net. [70.186.126.197]) by smtp.googlemail.com with ESMTPSA id r15sm3734592oor.35.2020.08.10.09.48.35 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Aug 2020 09:48:35 -0700 (PDT) Subject: Re: SQL Question about like To: pgsql-general@lists.postgresql.org References: <00d20cc2-0c97-8ce7-768a-a2c8bc396d19@gmx.de> From: Ron Message-ID: Date: Mon, 10 Aug 2020 11:48:34 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <00d20cc2-0c97-8ce7-768a-a2c8bc396d19@gmx.de> Content-Type: multipart/alternative; boundary="------------7B7CFF03EB447014B5815550" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------7B7CFF03EB447014B5815550 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 8/10/20 11:37 AM, pgml@gmx.de wrote: > Hello, > > my SQL question is, why psql doesn't return the record? > > create table lll (text char(100)); > insert into lll (text) values ('10% - Ersthelfer'); > > select * from lll where text like '10% - Ersthelfer'; > > Other databases (Maria, SQL Server, YARD) do this. > What can I do in pg, to get the result? Add a wildcard character.  (Also, why use LIKE in an equality?) test=# select * from lll where text like '10% - Ersthelfer';  text ------ (0 rows) test=# select * from lll where text like '10% - Ersthelfer%'; text --------------------------------------------------------------  10% - Ersthelfer (1 row) test=# test=# test=# select * from lll where text = '10% - Ersthelfer'; text --------------------------------------------------------------  10% - Ersthelfer (1 row) -- Angular momentum makes the world go 'round. --------------7B7CFF03EB447014B5815550 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 8/10/20 11:37 AM, pgml@gmx.de wrote:
Hello,

my SQL question is, why psql doesn't return the record?

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

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

Other databases (Maria, SQL Server, YARD) do this.
What can I do in pg, to get the result?

Add a wildcard character.  (Also, why use LIKE in an equality?)

test=# select * from lll where text like '10% - Ersthelfer';
 text
------
(0 rows)

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

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


--
Angular momentum makes the world go 'round.
--------------7B7CFF03EB447014B5815550--