在IN条件下使用LOWER [英] using LOWER with IN condition
本文介绍了在IN条件下使用LOWER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个名为 comodity_group
的表,其结构如下:
assume I have a table named comodity_group
and the structure looks like:
+----------+-------+
| group_id | name |
+----------+-------+
| 1 | Data1 |
+----------+-------+
| 2 | Data2 |
+----------+-------+
| 3 | data3 |
+----------+-------+
我有以下查询
SELECT * FROM comodity_group WHERE name IN('data1','data2','data3')
查询返回0结果,因为条件全为小写(请注意,条件也是动态的,这意味着它可以是Data1或daTa1等)
the query return 0 result, because condition is all in lowercase (note that the condition is also dynamic, meaning it can be Data1 or daTa1, etc)
所以我想将条件和字段名都用小写字母表示
so I want to make both condition and field name in lowercase, in other word case insensitive.
推荐答案
您可以将姓名数据转换为小写
You can convert your name data to lowercase
SELECT * FROM comodity_group WHERE lower(name) IN('data1','data2','data3')
这篇关于在IN条件下使用LOWER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文