smart190 Posted October 8, 2009 Share Posted October 8, 2009 Hi,I need some help to bulid stored procedure or some query that can read from table column some text (where separator is example ",") and put it some other table rows.For example:create table #test(line varchar(100))insert into #test(line) values ('test1, test2, test3')now is result like this: line1 test1, test2, test3what i need is that word will be in different rows: line1 test12 test23 test3 Link to comment Share on other sites More sharing options...
PravinBhat Posted October 12, 2009 Share Posted October 12, 2009 if using php .....then try this one<?php//connect;//set query;// execute the query;while($re=mysql_fetch_array($result_of_query)){echo $re[0]."<br>";echo $re[1]."<br>";echo $re[2]."<br>";}//Thats alll !!!//my sql close?> Link to comment Share on other sites More sharing options...
smart190 Posted October 12, 2009 Author Share Posted October 12, 2009 if using php .....then try this one<?php//connect;//set query;// execute the query;while($re=mysql_fetch_array($result_of_query)){echo $re[0]."<br>";echo $re[1]."<br>";echo $re[2]."<br>";}//Thats alll !!!//my sql close?>tnx but I need that query in SQL Link to comment Share on other sites More sharing options...
justsomeguy Posted October 12, 2009 Share Posted October 12, 2009 Check the manual for whatever database you're using, check the string functions and things like that. You should be able to use a split or explode function to get the parts and loop through them. If the database doesn't have a split or explode, you'll need to do that yourself. That would involve using a function to find the position of a character (the comma), and then a substring function to get the part of the string you're interested in. MySQL has the INSTR function to find the position of a substring, and the SUBSTR or SUBSTRING functions to get part of the string. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.