homepage Welcome to WebmasterWorld Guest from 54.227.40.166
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Mysql searching
SQL, matching characters
HeadBut




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

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

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

 

HeadBut




msg:3697127
 3:16 pm on Jul 12, 2008 (gmt 0)

LIKE doesn't seem to work cause sometimes the strings LookingAt is missing the first character "0"

Chris_Mohr




msg:3697234
 8:03 pm on Jul 12, 2008 (gmt 0)

have you looked at SUBSTRING?

HeadBut




msg:3697478
 1:26 pm on Jul 13, 2008 (gmt 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

Chris_Mohr




msg:3697496
 3:03 pm on Jul 13, 2008 (gmt 0)

Something like this should work.

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved