Samuel Budlong
Samuel Budlong

Reputation: 69

Check if a string contains any integers in SQLite

I have a database with fields for movie_title, imdb_rating, and genre. How can I use SQLite to select movies that have numbers in the title? I'm trying this code, which isn't working:

SELECT * FROM movies
WHERE movie_title like '%[0-9]%';

I've looked at other similar questions, and the answers look something like the above, but I can't figure out what about my code is going wrong. Thank you for any help.

Upvotes: 1

Views: 1176

Answers (1)

GMB
GMB

Reputation: 222462

In SQLite you could do this with glob- unless like, it supports character classes:

select *
from moveis
where movid_id glob '*[0-9]*'

Upvotes: 5

Related Questions