If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
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, 12: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-05-04, 23: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, 00: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

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