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 1o91NY-0007zn-EO for pgsql-general@arkaria.postgresql.org; Wed, 06 Jul 2022 09:31:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o91NX-0005UZ-79 for pgsql-general@arkaria.postgresql.org; Wed, 06 Jul 2022 09:31:27 +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 1o91NW-0005S4-Os for pgsql-general@lists.postgresql.org; Wed, 06 Jul 2022 09:31:26 +0000 Received: from mail.epaxios.com ([5.9.99.247]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o91NU-00055a-BV for pgsql-general@postgresql.org; Wed, 06 Jul 2022 09:31:26 +0000 Received: from hetzner1.epaxios.com (localhost.localdomain [127.0.0.1]) by mail.epaxios.com (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 2669VK5q012671; Wed, 6 Jul 2022 11:31:21 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=froehlich.priv.at; s=hetzner1; t=1657099881; bh=4JcHzrdj4Kn2KxkdUuPipaKPMUZBoUZB2Jichzq+5A0=; h=Date:From:To:Subject:From; b=j/tNjf7TPVo6k7U3u5bO5yb+ZweOJTzcFZwr+IMfCMsx4DaLDZXrbjVuywosrQ2Hx AawogtgJE0s2ONsceFPceIp8Ugop33VfuAVizQ/O/k9/DBRw0wCuFF0VZ5CXxJstqY caGcGRXqjJSeWvl9Mbr2EzuNxtvUB80Ndk8h7NMk= Received: (from sfroehli@localhost) by hetzner1.epaxios.com (8.14.4/8.14.4/Submit) id 2669VKFh012670; Wed, 6 Jul 2022 11:31:20 +0200 Date: Wed, 6 Jul 2022 11:31:20 +0200 From: Stefan Froehlich To: pgsql-general@postgresql.org Subject: unable to understand query result Message-ID: <20220706093120.GA11952@static.231.150.9.176.clients.your-server.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I have a database returing these result sets for two almost identical queries: #v+ $ select id, pid, length(pid), md5(pid) from product where pid like '8000000'; id | pid | length | md5 ------+---------+--------+---------------------------------- 3594 | 8000000 | 7 | 60b5792913f4acbccf45c281fa9e3c9f (1 row) $ select id, pid, length(pid), md5(pid) from product where pid like '%8000000'; id | pid | length | md5 ------+---------+--------+---------------------------------- 3594 | 8000000 | 7 | 60b5792913f4acbccf45c281fa9e3c9f 722 | 8000000 | 7 | 60b5792913f4acbccf45c281fa9e3c9f (2 rows) #v- There should be only one product with this id (no unique key, because this is not a general constraint but just the current situation), but there are two. Looking for it with query 1 I got only one result, suspecting leading or trailing blanks I found the other one using the wildcard. But: What is wrong here? There must be some difference between the two product ids, but with the same md5-hash there seems to be none. This is by far too trivial to be a postgresql-bug, but what exactly am I missing here? Bye, Stefan