题解 | #检索产品名称和描述(二)#
检索产品名称和描述(二)
https://www.nowcoder.com/practice/669913837a7648f9aa0caaf6a88c834f
# 本题的思路与上题恰恰相反,因此解题的思路几乎一样,同样可以采用三种方式 # 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
# 本题中各函数的参考内容如下:
instr(filed,str)、not like:https://blog.csdn.net/u014651560/article/details/124248358
locate函数:https://blog.csdn.net/hello_world_9664/article/details/124159818
locate函数:https://blog.csdn.net/hello_world_9664/article/details/124159818