在使用DB2 查询 char 型字段应用like时遇到这样一个问题
表名student,字段ID,ID的数据类型为char 长度是20
表中ID数据为
000123
000125
000126
001123
想通过select * from student where ID like '%123'查询 ID尾号是123的数据
结果什么也没查到,百度之后,了解DB2 CHAR 型这样查是有问题的
处理办法是这个样子的由于我的数据都是六位,所以要补齐后边的14位
语句为:
select * from student where ID like '%123______________'
注意这里有14个_
这样就可以查到想要的
001123
000123
两条记录所有中的数据