Re: Like Query help

From: "aNullValue (Drew Stemen)" <drew(at)anullvalue(dot)net>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Like Query help
Date: 2021-01-15 00:37:23
Message-ID: 2d360fd0-463a-4c75-b4de-ee4239b7b345@www.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 2021-01-14T19:27:23-05:00, Bret Stern <bret_stern(at)machinemanagement(dot)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;

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message rob stone 2021-01-15 00:51:41 Re: Strange (and good) side effect of partitioning ?
Previous Message Bret Stern 2021-01-15 00:27:23 Like Query help