Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 仅选择ID';没有完全数值的_Sql - Fatal编程技术网

Sql 仅选择ID';没有完全数值的

Sql 仅选择ID';没有完全数值的,sql,Sql,我只想在某一列中选择ID,该列不包含唯一的数值。 例如: 我想选择: a12345 但不是: 123456 这是一个nvarchar(15)字段 这在SQL中可能吗 问候对于第一个字符的具体问题,您可以执行以下操作: where substr(col, 1, 1) not between '0' and '9' 这几乎适用于任何数据库(尽管substr()可能拼写为substring()) 有更好的解决方案,但它们是特定于给定数据库的。尝试“isnumeric”(假设MSSQL) 如果是S

我只想在某一列中选择ID,该列不包含唯一的数值。 例如:

我想选择:

a12345
但不是:

123456
这是一个nvarchar(15)字段

这在SQL中可能吗


问候

对于第一个字符的具体问题,您可以执行以下操作:

where substr(col, 1, 1) not between '0' and '9'
这几乎适用于任何数据库(尽管
substr()
可能拼写为
substring()

有更好的解决方案,但它们是特定于给定数据库的。

尝试“isnumeric”(假设MSSQL)


如果是SQL Server 2012+,我将使用
try\u convert()
,它会为任何转换错误返回NULL

示例

Declare @YourTable Table ([ID] nvarchar(15))
Insert Into @YourTable Values 
 ('a12345')
,('12345')
,('123-45')
,('12345z')

Select * from @YourTable
 where try_convert(int,ID) is null
返回

ID
a12345
123-45
12345z

用你正在使用的数据库标记你的问题。你正在使用哪个数据库管理系统?(答案可能是特定于产品的。)
ID
a12345
123-45
12345z