# 1.locate函数:Locate(str,sub) > 0,表示sub字符串包含str字符串;Locate(str,sub) = 0,表示sub字符串不包含str字符串。
select prod_name,prod_desc from Products
where locate("toy",prod_desc) = 0
order by prod_name asc
# 2.instr(filed,str)函数:返回str子字符串在filed字符串的第一次出现位置
select prod_name,prod_desc from Products
where instr(prod_desc,"toy") = 0
order by prod_name asc
# 3.not like
select prod_name,prod_desc from Products
where prod_desc not like "%toy%"
order by prod_name asc
SQL76 检索产品名称和描述(二)
最新推荐文章于 2024-08-09 09:47:03 发布
文章介绍了如何在SQL查询中使用locate函数检查产品描述中是否包含特定字符串toy,以及使用instr查找首次出现位置和notlike操作符排除包含toy的产品,对Products表中的产品按名称升序排列。
摘要由CSDN通过智能技术生成