scotchegg78 Posted December 16, 2008 Share Posted December 16, 2008 Hi guys I have a var 255 column called data which has the format ' part1,part2'. I want to extract and put part1 into its own column, and part2 into its own column. so something like update table set part1 = data(part1); What can i use to match all text before the , a reg expression?? thanks Quote Link to comment https://forums.phpfreaks.com/topic/137208-solved-quick-question-extract-string-into-2-parts-from-txt-column-seperated-by/ Share on other sites More sharing options...
waterssaz Posted December 16, 2008 Share Posted December 16, 2008 If you are querying the database directly then try using a substring combined with a charindex to get the position of the comma as this will probably vary with the different string lengths. Quote Link to comment https://forums.phpfreaks.com/topic/137208-solved-quick-question-extract-string-into-2-parts-from-txt-column-seperated-by/#findComment-716763 Share on other sites More sharing options...
scotchegg78 Posted December 16, 2008 Author Share Posted December 16, 2008 thanks i used this update table set part1 = (substring_index(data,',',1)) for first part and update table set part2 = (substring_index(data,',',-1)) for the 2nd part maybe a better way, but it did hte job Quote Link to comment https://forums.phpfreaks.com/topic/137208-solved-quick-question-extract-string-into-2-parts-from-txt-column-seperated-by/#findComment-716764 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.