0

Hey how can I check if the input has 5 numbers? I tried everything like isnumeric/LIKE '%[0-9]%' they all not working...

I tried the following but it doesn't work.. please help

CREATE TABLE Code ( PIN TEXT NOT NULL, CHECK(LENGTH(title) = 5), CHECK(title LIKE '[0-9][0-9][0-9][0-9][0-9]'));
2
  • What rdbms are you using? Commented Oct 16, 2021 at 14:48
  • I am using sqlite3 Commented Oct 16, 2021 at 14:50

1 Answer 1

1

You can use GLOB operator:

CREATE TABLE Code ( 
  PIN TEXT NOT NULL,
  title TEXT,
  CHECK(title GLOB '[0-9][0-9][0-9][0-9][0-9]')
);

See the demo.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.