如何在 SQL Server 'LIKE' 中匹配数字.
How to match numbers in SQL Server 'LIKE'.
SpaceName
------------
| New_Space_1
| .
| .
| New_Space_8
| New_Space_9
| New_Space_10
| New_Space_11
| New_Space_SomeString
| New_Space_SomeString1
以上是我的表格内容.我只想获取以数字字符结尾的记录,即我想要从 New_Space_1
到 New_Space_11
的记录.
Above is my table contents.
I want to get only records ending with Numeric chars, ie I want the records from New_Space_1
to New_Space_11
.
不想要 New_Space_SomeString
和 New_Space_SomeString1
我有一些这样的查询.
SELECT SpaceName FROM SpaceTable
WHERE SpaceName LIKE 'New_Space_%'
但这会返回所有记录.
@SteveKass 的这个解决方案非常有效.
This solution from @SteveKass works perfect.
SELECT SpaceName FROM SpaceTable WHERE SpaceName LIKE 'New[_]Space[_]%' AND SpaceName NOT LIKE 'New[_]Space[_]%[^0-9]%'
这篇关于SQL Server 中数字的通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!