alecks Posted February 24, 2007 Share Posted February 24, 2007 I want to retrieve only a certain length of data from an entry in a mysql table, how would I do that? ex. I only want the first 5 letters in the entry "example", so what should be returned to me is "examp". Can I do this with only a mysql query or will I have to use some PHP functions to clip the string, and if it is the latter what functions do I have to use? Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted February 24, 2007 Share Posted February 24, 2007 SELECT LEFT(field,5) FROM table_name Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted February 24, 2007 Share Posted February 24, 2007 that help at all? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 24, 2007 Share Posted February 24, 2007 You can also use PHP's substr() Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted February 24, 2007 Share Posted February 24, 2007 You can also use PHP's substr() Yea, if you wanna trim down the data after it is pulled then you can do $original = substr($original, 0, 5); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.