Shudmeyer
Shudmeyer

Reputation: 352

getting only the four digits in mysql where condition

I have a field name "value" which contains 4 digits, 8 digits and 16 digits. How do I get only the four digits using mysql statement "SELECT" with where condition?

Here are the example.

value

1001 90812323 8928123458341235 0123 4521 84920192 7584

Getting only the "1001,0123,4521 and 7584".

Is this possible?

Upvotes: 1

Views: 1405

Answers (2)

Siavashmusic
Siavashmusic

Reputation: 56

SELECT * FROM tb WHERE char_length(value) = 4

check this link: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html

Upvotes: 2

rationalboss
rationalboss

Reputation: 5389

SELECT value FROM table WHERE LENGTH(value)=4;

Upvotes: 5

Related Questions