Thread: Like Query help

Like Query help

From
Bret Stern
Date:
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-"


results

"SNJ";"000001 1X1 CORNER BULLNOSE";"1x1 Corner Double 
Bullnose";"SYZY";"";"";"EACH";""
"SNJ";"0001 BRIGHT WHITE LISTELLO";"Bright White Listello 
5/8x12";"VILL";"";"";"EACH";""
"SNJ";"0001 CUSTOM 1X6 BULLNOSE LONG";"Custom 1x6 Bullnose on 6" 
Side";"SYZY";"";"";"EACH";""
"BUR";"000936MOD1P4";"Matte Cappuccino Tile";"AMOL";"";"";"SF";""
"SNJ";"000936MOD1P4";"Matte Cappuccino Tile";"AMOL";"";"";"SF";""
"BUR";"0009S4369MOD1P2";"Matte Cappuccino BN on 6"";"AMOL";"";"";"EA";""
"SNJ";"0009S4369MOD1P2";"Matte Cappuccino BN on 6"";"AMOL";"";"";"EA";""
"BUR";"0009S4639MOD1P2";"Matte Cappucino BN on 3"";"AMOL";"";"";"EA";""
"SNJ";"0009S4639MOD1P2";"Matte Cappucino BN on 3"";"AMOL";"";"";"EA";""
"BUR";"0009SCL4369M1P2";"Matte Cappuccino Left 
Bullnose";"AMOL";"";"";"EA";""
"SNJ";"0009SCL4369M1P2";"Matte Cappuccino Left 
Bullnose";"AMOL";"";"";"EA";""
"BUR";"0009SCR4369M1P2";"Matte Cappuccino Right BN";"AMOL";"";"";"EA";""
"SNJ";"0009SCR4369M1P2";"Matte Cappuccino Right BN";"AMOL";"";"";"EA";""
"SNJ";"0014 SURF 2X4 OFFSET";"Surf 2x4 Offset Mosaic";"VILL";"";"";"EACH";""
"SNJ";"0014 SURF LISTELLO";"Surf Listello 5/8x12";"VILL";"";"";"EACH";""
"SNJ";"0015 ICE 2X4 OFFSET";"Ice 2x4 Offset Mosaic";"VILL";"";"";"EACH";""





Re: Like Query help

From
"aNullValue (Drew Stemen)"
Date:
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
actuallydesired 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,
''asmat_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;



Re: Like Query help

From
Bret Stern
Date:
Works. Thanks for the help. I will read the docs

Best

On 1/14/2021 4:37 PM, aNullValue (Drew Stemen) wrote:
> 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
actuallydesired 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,
''asmat_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;
>
>