在sql中找不到类似查询的结果? [英] No result found in sql for like query ?
本文介绍了在sql中找不到类似查询的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张特定格式的桌子
id LocationId
1 1,2,31,4,5 >
2 31,7
3 5,41
4 1,5
5 2
i使用'like'进行搜索,但它仅用于某些表达式,例如'%1%',如'%1,2%',如'%4,5%'但当我的表情像'1,31'或像'2,5'不起作用。
请为超越结果提供帮助。 :(
I have a table in the particular format
id LocationId
1 1,2,31,4,5
2 31,7
3 5,41
4 1,5
5 2
i am using ' like ' for searching but its working only on some expression for example- like '%1%' , like '%1,2%' , like '%4,5%' but when my expression is like '1,31' or like '2,5' is not working.
Please help for the transcendent result. :(
推荐答案
你的表没有'1,31'或类似'2,5'的东西。相反,它可能像'1%,31 %'或者喜欢'%2%,5%'。
Your table doesn't have anything like '1,31' or like '2,5'. Instead it can be like '1%,31%' or like '%2%,5%'.
它不会提供输出,因为你的数据不包含您正在查找的值。
因为Like适用于模式。请检查喜欢 [ ^ ]
已添加......
您可以使用 IN [ ^ ]
编辑
查看拆分价值
如何在Sql Server中拆分列值 [ ^ ]
希望这会对你有所帮助。
干杯
Hi,
It will not give output, since your data does not contains the values which you are looking.
Since Like works on Patterns. Check this Like[^]
Added...
You can make use of IN[^]
Edited
Check this for Splitting values
How to Split a Column value in Sql Server[^]
Hope this will help you.
Cheers
嗨Rajeev,
从test9028396中选择*其中locationid如'%[25]%'
Hi Rajeev ,
select * from test9028396 where locationid like '%[25]%'
这篇关于在sql中找不到类似查询的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文