Welcome to WebmasterWorld Guest from 54.167.46.29

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Mysql searching

SQL, matching characters

     
3:08 pm on Jul 12, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Sept 2, 2004
posts:187
votes: 0


trying to match the first 5 characters in a string is there function for this?

SELECT *
From TheTable
WHERE FirstFiveCahracters(TheTable.LookingAt) = Lookingfor

3:16 pm on July 12, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Sept 2, 2004
posts:187
votes: 0


LIKE doesn't seem to work cause sometimes the strings LookingAt is missing the first character "0"
8:03 pm on July 12, 2008 (gmt 0)

New User

5+ Year Member

joined:July 31, 2006
posts: 16
votes: 0


have you looked at SUBSTRING?
1:26 pm on July 13, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Sept 2, 2004
posts:187
votes: 0


The sometimes missing first character "0" messes things up. Not sure how to get a match with SUBSTRING. It's kinda like a zip code 07654. I need to match with three conditions like:

07654
7654
076541122

thanks for your help

3:03 pm on July 13, 2008 (gmt 0)

New User

5+ Year Member

joined:July 31, 2006
posts:16
votes: 0


Something like this should work.

select * from table where LookingAt REGEXP '^0?7654'