简体   繁体   English

如何在 Presto SQL 中使用 NOT LIKE 和 % 从搜索中排除项目?

[英]How to exclude items from search using NOT LIKE and % in Presto SQL?

I have the following query that returned an error: mismatched input 'LIKE'.我有以下查询返回错误:不匹配的输入“LIKE”。 Expecting: expression期待:表达

select * from sales
where item_name NOT LIKE '%Tortoise%' 

The image below illustrates what I want to get from my source data.下图说明了我想从源数据中得到什么。 I want records that do not contain the keyword "Tortoise".我想要不包含关键字“Tortoise”的记录。

Appreciate any advice on how to correct this syntax, thank you.感谢有关如何更正此语法的任何建议,谢谢。

This may get you the expected result.这可能会为您带来预期的结果。

select * 
from sales
where item_name NOT IN (
   select * 
   from sales
   where item_name LIKE '%Tortoise%'
) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM