Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to know how to get only digit records

Status
Not open for further replies.

EdLentz

Technical User
Mar 20, 2002
85
US
I have a DB that I had an ID field that has numerals and letters in some of the entries. I want to get ONLY the entries with the digits for the id entry. How can I do this?? Here is what I have so far

SELECT * FROM `sip` WHERE `keyword` LIKE 'secret' AND `id` like 102

This will pull the record 102. The id entries will be any digit up to a length of 6 digits long.

Can someone show me the way?

Thanks!
 
use a regular expression

Select ... ... REGEXP '[0-9]{n,x}' ... ...


n = min length x = max length so '[0-9]{3,10}' means a string of numerals min length 3, max length 10

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
Thanks Chris that works perfectly!

Have a great weekend, mine just got better.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top