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 1l0D7j-00005D-PZ for pgsql-general@arkaria.postgresql.org; Fri, 15 Jan 2021 00:37:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l0D7i-0008Ur-E8 for pgsql-general@arkaria.postgresql.org; Fri, 15 Jan 2021 00:37:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l0D7h-0008Uh-4v for pgsql-general@lists.postgresql.org; Fri, 15 Jan 2021 00:37:54 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l0D7a-0001tt-8b for pgsql-general@lists.postgresql.org; Fri, 15 Jan 2021 00:37:52 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id E99235C00F0 for ; Thu, 14 Jan 2021 19:37:43 -0500 (EST) Received: from imap8 ([10.202.2.58]) by compute3.internal (MEProxy); Thu, 14 Jan 2021 19:37:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anullvalue.net; h=mime-version:message-id:in-reply-to:references:date:from:to :subject:content-type; s=fm1; bh=3Tnsamn82QB044a0p1j0RD5UFlwMZoZ YBh3v2tDJn2k=; b=kJRjkiUKBRWWyENv3/fO6ShnXTUaG9h/V7PdwRduLn9jANA HRK0dSTfI8vOxb0gfyelppzhLJokM5iehS61trJ/sSiwLlV/rldj6A4/Y8dhs59X a94OSJZNTOqGS9WrMNcIexQwqoZWAh3XrYcCKHjc+5m1U2ljRQ8/qGGa1ibJqWvl gLsnUC1C7Ba8R73ck2WlNjOFVPiqFpRt41VOJkxDVF9kawffaWQYhpu5QOKMSiJl 4yYtIKBQh5awAnRPhyFN+nei/pQXac+KKv6d2asi15lUHZxgQ2DOofFaH4EyROkA IB2wIpvnkPOG5eLofohbDuV6/mD3r/Plo3aee0Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=3Tnsam n82QB044a0p1j0RD5UFlwMZoZYBh3v2tDJn2k=; b=W1e2vLuwvq7oYAIf6ryRmm Nf4E533yRLBCP7KYpEfUitEry/FxXm7C4FUr6GvNerpozr62MbdEPWma64I96Gpt fKPHvKbZAcbm/DYEwXi8nNrpIL2EobEgxsUFIc3e84Xs/sCLJZDA/Zt18muDdISy lUoLhy1HtTVbPgKTeMyBXLO1OzSF19qK/pB0CKS135WNtHUoavTiIQANfavxIFGn Yvxte0IGhKdcxui/Ui9/jhqg9N/Zxuqu3odPm60xEm/vDd6rFZV9fiGMaS57gtje rwo0IjyHqVkGEIe0VfcPEuICvOXdGgM2i6/+9KKRTeBswMy50PIlysd+hU/htr1g == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrtddugddvgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesthdtre dtreertdenucfhrhhomhepfdgrpfhulhhlgggrlhhuvgculdffrhgvficuufhtvghmvghn mddfuceoughrvgifsegrnhhulhhlvhgrlhhuvgdrnhgvtheqnecuggftrfgrthhtvghrnh epvddtgfeffeduleefffekteeiheffffdugfeffeetvdegfeffhffhvefggfeghfdunecu ffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurhgvfiesrghnuhhllhhvrghluhgvrdhn vght X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id A0D43520094; Thu, 14 Jan 2021 19:37:43 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-45-g4839256-fm-20210104.001-g48392560 Mime-Version: 1.0 Message-Id: <2d360fd0-463a-4c75-b4de-ee4239b7b345@www.fastmail.com> In-Reply-To: References: Date: Thu, 14 Jan 2021 19:37:23 -0500 From: "aNullValue (Drew Stemen)" To: pgsql-general@lists.postgresql.org Subject: Re: Like Query help Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk At 2021-01-14T19:27:23-05:00, Bret Stern sent: > query > > select company_code, item_code, item_description, product_line, > udf_item_width, udf_item_length, sales_unit_measure, ''as mat_type from > mas_combined_item_master where company_code='BUR' or company_code='SNJ' > or company_code='EBC' and udf_edb_managed='' > and item_code LIKE 'S-%' order by item_code; > > comment > > Second column is item_code...why are these items in the results. > Expecting the query to return results where the item_code > > starts with "S-" and includes any othervalue past "S-" > Based on your description, your query is not correct; you should rewrite it, likely using parenthesis to define your actually desired value expression. See also https://www.postgresql.org/docs/13/sql-expressions.html#SYNTAX-EXPRESS-EVAL This may or may not be what you intended: SELECT company_code, item_code, item_description, product_line, udf_item_width, udf_item_length, sales_unit_measure, ''as mat_type FROM mas_combined_item_master WHERE (company_code='BUR' OR company_code='SNJ' OR company_code='EBC') AND udf_edb_managed='' AND item_code LIKE 'S-%' ORDER BY item_code;