返回第一个字符是非字母的行 [英] Return rows where first character is non-alpha

查看:50
本文介绍了返回第一个字符是非字母的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检索 SQLite 中以任何非字母字符开头的所有列,但似乎无法使其正常工作.我目前有这个代码,但它返回每一行:

I'm trying to retrieve all columns that start with any non alpha characters in SQlite but can't seem to get it working. I've currently got this code, but it returns every row:

SELECT * FROM TestTable WHERE TestNames NOT LIKE '[A-z]%'

有没有办法检索所有 TestNames 的第一个字符不是字母表的一部分的行?

Is there a way to retrieve all rows where the first character of TestNames are not part of the alphabet?

推荐答案

你只去第一个字符吗?

select * from TestTable WHERE substr(TestNames,1) NOT LIKE '%[^a-zA-Z]%'

substr 函数(在某些 SQL 语言中也可以称为 left())将帮助您隔离字符串中的第一个字符.

The substr function (can also be called as left() in some SQL languages) will help isolate the first char in the string for you.

也许是 sqllite 中的 substr(TestNames,1,1),我没有现成的实例来测试那里的语法.

edit: Maybe substr(TestNames,1,1) in sqllite, I don't have a ready instance to test the syntax there on.

添加:

select * from TestTable WHERE Upper(substr(TestNames,1,1)) NOT in ('A','B','C','D','E',....)

似乎不是最佳的,但在功能上会起作用.不确定在 SQLlite 中使用哪些字符命令来处理一系列字母.

Doesn't seem optimal, but functionally will work. Unsure what char commands there are to do a range of letters in SQLlite.

我使用upper"来制作它,所以你不需要在 not in 语句中使用小写字母......有点希望 SQLlite 知道那是什么.

I used 'upper' to make it so you don't need to do lower case letters in the not in statement...kinda hope SQLlite knows what that is.

这篇关于返回第一个字符是非字母的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆