[英]Ignore Case sql query
I am trying to basically ignore the case sensitivity for my db2 sql select * query, so that I can populate the products to my catalogue page.我试图基本上忽略我的 db2 sql select * 查询的区分大小写,以便我可以将产品填充到我的目录页面。 Ex.
前任。 If I type in my search bar 'squeege', I want the item 'Squeege' to populate, even if there is a difference in Upper/lower case.
如果我在搜索栏中输入“squeege”,我希望填充“Squeege”项,即使大小写有所不同。 What is the best way to do this, based on the code I have below?
根据我下面的代码,最好的方法是什么?
var searchProduct = "select * from LISTOFPRODUCTS where ITEM LIKE '%" + searchValue + "%'"
Thanks in advance for the help :)在此先感谢您的帮助 :)
I think this could work:我认为这可以工作:
var searchProduct = "select * from LISTOFPRODUCTS where UPPER(ITEM) LIKE UPPER('%" + searchValue + "%'")
Also the same with LOWER()
LOWER()
也一样
Note that the trick is parse both values to UPPER()
or LOWER()
to match them.请注意,诀窍是将两个值解析为
UPPER()
或LOWER()
以匹配它们。
You can use the function LOWER()
.您可以使用函数
LOWER()
。 For example:例如:
var searchProduct = "select * from LISTOFPRODUCTS where LOWER(ITEM) LIKE '%" + searchValue + "%'"
您还可以考虑使用REGEXP_LIKE
具有不区分大小写的选项i
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.