[thelist] Comma delimited string in SQL

M.G. Noriega manuel at simplelogica.net
Mon Oct 13 10:02:28 CDT 2003


El lun, 13-10-2003 a las 16:26, Stevenson N escribió:
> Hi all,
> I have comma delimited string i.e. 1,2,4,5. I want to loop through each data in the string as i insert the data in a table.
>  
> How can i achieve this? Please assist!
> 
> 

Which language are you working with? The PHP solution would involve
explode() and foreach{} and is pretty easy

$mystr = "1,2,4,5";

$myarr = explode($mystr);

// Now $myarr = array(1,2,4,5);

foreach ($myarr as $mything)
{
	// Insert $mything into database
}


-- 
Manuel González Noriega
Simplelógica, construcción web @ http://simplelogica.net
Logicola es el weblog de Simplelógica http://simplelogica.net/logicola/



More information about the thelist mailing list