SQL查询求助!!我正在尝试选择不以数字开头的行

发布于 2024-10-02 06:22:32 字数 224 浏览 7 评论 0 原文

我的表中有 10,001 行,除了一行之外的所有行都以数字开头。我需要找到这一行不以数字开头,甚至不包含数字。

这就是我所拥有的:

Select col1 from table1 where col1 not like '?%'

这还接近吗?我需要找到没有数字的行...

谢谢!

更新:我正在使用 sqlite 数据库

I have 10,001 rows in my table, and all of the rows except one start with a number. I need to find this one row that doesn't start with a number, or even that doesn't contain a number.

So this is what I have:

Select col1 from table1 where col1 not like '?%'

Is this even close? I need to find the row that doesn't have a number...

Thanks!!

UPDATE: I am using a sqlite database

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

倾听心声的旋律 2024-10-09 06:22:32

使用:

SELECT col1
  FROM table1 
 WHERE SUBSTR(col1, 1, 1) NOT BETWEEN 0 AND 9

参考:

Use:

SELECT col1
  FROM table1 
 WHERE SUBSTR(col1, 1, 1) NOT BETWEEN 0 AND 9

Reference:

旧情勿念 2024-10-09 06:22:32

在 Sql Server 上,

Select * From table
Where col1 Like '[^0-9]%'

编辑:不知道 SQLLIte 上是否有等效的,

但这会起作用......

Select * From table
Where col1 Not Like '0%' 
   And col1 Not Like '1%'
     ...
   And col1 Not Like '9%'

On Sql Server,

Select * From table
Where col1 Like '[^0-9]%'

EDIT: Don't know if there is an equivilent on SQLLIte,

but this will work...

Select * From table
Where col1 Not Like '0%' 
   And col1 Not Like '1%'
     ...
   And col1 Not Like '9%'
帅气称霸 2024-10-09 06:22:32

代码项目中有一篇文章允许您将 Regex 与 Ms SQL 一起使用。

希望这有帮助。

There is a post in code project that allow you to use Regex with Ms SQL.

Hope this help.

软糯酥胸 2024-10-09 06:22:32

最简单的方法可能是只注意您没有使用数字;而是使用数字。您使用的字符串中恰好有数字。在这种情况下,您可以这样做

select * from table1 where col1 not between '0' and '9:'; 

(其中冒号是“9”后面的 ASCII 字符;这样就不会找到“9999999”)。

它应该比其他一些建议(例如,检查第一个字符的值)便宜很多。

The easiest way might be to just note that you're not using numbers; you're using strings that happen to have numbers in them. In this case, you can do

select * from table1 where col1 not between '0' and '9:'; 

(where the colon is the ASCII character after '9'; this way '9999999' won't be found).

It should be a lot less expensive than some of the other suggestions (e.g., checking the value of the first character).

抱猫软卧 2024-10-09 06:22:32

@Dueber 让我思考,你不能这样做吗?

SELECT * FROM table1 WHERE col1 > '9'

抓住第一个字符,看看它是否是数字。

SELECT *
FROM   table1
WHERE  ISNUMERIC(SUBSTRING(col1,1,1)) = 0

子字符串

ISNUMERIC

@Dueber got me thinking, couldn't you just do this?

SELECT * FROM table1 WHERE col1 > '9'

Grab the first character, see if it's numeric.

SELECT *
FROM   table1
WHERE  ISNUMERIC(SUBSTRING(col1,1,1)) = 0

SUBSTRING

ISNUMERIC

楠木可依 2024-10-09 06:22:32

使用:

IsNumeric(Substring(col1,1,1))!=1

Use:

IsNumeric(Substring(col1,1,1))!=1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文