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 > Check if part of a field is numeric.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-04-04, 08:13
beyond cool beyond cool is offline
Registered User
 
Join Date: Sep 2003
Posts: 39
Check if part of a field is numeric.

Hi all,

I want to check if part of a field is numeric. For example, I have a field containing values such as

Anne
Anne-France
Annemary
Anne123

I want to find Anne123 by checking if the contents of the field past 'Anne' is numeric.
Reply With Quote
  #2 (permalink)  
Old 10-04-04, 08:20
beyond cool beyond cool is offline
Registered User
 
Join Date: Sep 2003
Posts: 39
I currently have:

SELECT
max(username) as lastUsername
FROM
tbUser usr
WHERE
left(usr.username, len(username)) = username
and format(right(usr,username, char_length(usr.username) - len(username)) = cast(right(usr,username, char_length(usr.username) - len(username)) as unsigned)

where the italic text is simply a variable filled in with PHP.
Reply With Quote
  #3 (permalink)  
Old 10-04-04, 08:53
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
... where username regexp "^Anne[[:digit:]]+"

or something like that
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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