• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 374
  • Last Modified:

mysql check number length

is it possible to check a numbers length in mysql because the zeros are missing off the beginning of some numbers.. is there away to check if its 9 in length and add a zero in the beginning if it is.

thanks in advance
  • 2
2 Solutions
Dave BaldwinFixer of ProblemsCommented:
'Numbers' do not have leading zeros (or trailing zeros to the right of a decimal point) because they contribute nothing to the value.  If you want leading zeros, you must convert it to a string and check it there.
HainKurtSr. System AnalystCommented:

HainKurtSr. System AnalystCommented:
or use

lpad(num, 9, '0')

you may need to cast it

lpad(cast(num as char), 9, '0')
MK15Author Commented:
thanks guys
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now