pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: aNullValue (Drew Stemen) <drew@anullvalue.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: Like Query help
Date: Thu, 14 Jan 2021 19:37:23 -0500
Message-ID: <2d360fd0-463a-4c75-b4de-ee4239b7b345@www.fastmail.com> (raw)
In-Reply-To: <f9c89cca-0f76-3616-705a-2d123dd03658@machinemanagement.com>
References: <f9c89cca-0f76-3616-705a-2d123dd03658@machinemanagement.com>

At 2021-01-14T19:27:23-05:00, Bret Stern <bret_stern@machinemanagement.com> 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;





view thread (3+ messages)  latest in thread

Message-ID: <2d360fd0-463a-4c75-b4de-ee4239b7b345@www.fastmail.com>
Permalink:  ../2d360fd0-463a-4c75-b4de-ee4239b7b345@www.fastmail.com/
Also on:    postgresql.org/message-id/2d360fd0-463a-4c75-b4de-ee4239b7b345@www.fastmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: drew@anullvalue.net
  Subject: Re: Like Query help
  In-Reply-To: <2d360fd0-463a-4c75-b4de-ee4239b7b345@www.fastmail.com>
  References: <f9c89cca-0f76-3616-705a-2d123dd03658@machinemanagement.com> <2d360fd0-463a-4c75-b4de-ee4239b7b345@www.fastmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox