Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
299 views
in Technique[技术] by (71.8m points)

sql - sqlite matching on a number

I can't seem to find a good way to match on an integer in SQLite without writing them all out, for example I'm looking to do something like this:

SELECT count(*)
FROM numbers
WHERE SUBSTR(numbers 1, 1) LIKE ':d'

But the above doesnt work and various versions of it either.

I can get it to work with:

SELECT count(*)
FROM numbers
WHERE SUBSTR(numbers 1, 1) IN ("1","2","3" [etc])

but this seems verbose.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you want to count the number of rows where the column number starts with a digit:

SELECT COUNT(*)
FROM numbers
WHERE SUBSTR(numbers, 1, 1) BETWEEN '0' AND '9'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...