Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > MySQL > Numeric string wildcards?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-04-04, 13:27
shealy shealy is offline
Registered User
 
Join Date: Dec 2002
Posts: 8
Question Numeric string wildcards?

Is it possible to search just numeric characters in a string using wildcards?

Example:

I want to find Clients with Code of 60111, 61234, etc. The field is varchar but the sequence I want is always 5 numerics starting with '6' (6####). However, there are also codes such as 6123A or 6055G, which I do not want included in my results.

When searching on
"ClientCode like '6%'"
or
"ClientCode like '6____'"

I get the codes included I do not want.

I know in Access I can search for just numeric values (ClientCode like '6####'). I've tried that in MySQL with no success so far. Is this possible?
Reply With Quote
  #2 (permalink)  
Old 03-06-04, 00:33
donsimon donsimon is offline
Registered User
 
Join Date: Jan 2004
Posts: 24
To be honest with you, I have never tried this. But right off the top of my head, what I would do is say left(field,5) > 60000, since if you get back, 6111A, it would be less than 60000.

Donny
__________________
http://www.phpscripts.com/
Reply With Quote
  #3 (permalink)  
Old 03-06-04, 01:19
vanekl vanekl is offline
Registered User
 
Join Date: Nov 2003
Posts: 91
you could also use regular expressions,

... WHERE ClientCode REGEXP "^6[0-9]{4}"
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On