mrherman Posted August 22, 2010 Share Posted August 22, 2010 Hi In a SELECT statement, I need to fetch a last name from a field up to but not including the comma, if there is one in the field. The field I need to select from is 13 chars wide, and is in the following format: Johnson, John Smith, Suzy Valadovichici Marks, Markie So, some last names take up the entire 13-char field. What I need from the above is: Johnson Smith Valadovichici Marks Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/211404-select-chars-in-a-name-field-but-stop-at-comma/ Share on other sites More sharing options...
fenway Posted August 22, 2010 Share Posted August 22, 2010 SUBSTRING_INDEX() is your friend. Quote Link to comment https://forums.phpfreaks.com/topic/211404-select-chars-in-a-name-field-but-stop-at-comma/#findComment-1102265 Share on other sites More sharing options...
mrherman Posted August 22, 2010 Author Share Posted August 22, 2010 Wow...Made to order! Thank you very much! Quote Link to comment https://forums.phpfreaks.com/topic/211404-select-chars-in-a-name-field-but-stop-at-comma/#findComment-1102401 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.