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? Link to comment https://forums.phpfreaks.com/topic/39964-limiting-length-of-data-pulled-from-table-in-mysql/ Share on other sites More sharing options...
magic2goodil Posted February 24, 2007 Share Posted February 24, 2007 SELECT LEFT(field,5) FROM table_name Link to comment https://forums.phpfreaks.com/topic/39964-limiting-length-of-data-pulled-from-table-in-mysql/#findComment-193244 Share on other sites More sharing options...
magic2goodil Posted February 24, 2007 Share Posted February 24, 2007 that help at all? Link to comment https://forums.phpfreaks.com/topic/39964-limiting-length-of-data-pulled-from-table-in-mysql/#findComment-193251 Share on other sites More sharing options...
Jessica Posted February 24, 2007 Share Posted February 24, 2007 You can also use PHP's substr() Link to comment https://forums.phpfreaks.com/topic/39964-limiting-length-of-data-pulled-from-table-in-mysql/#findComment-193252 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); Link to comment https://forums.phpfreaks.com/topic/39964-limiting-length-of-data-pulled-from-table-in-mysql/#findComment-193262 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.