hi all...
just wanna know can i 'explode' data in a mysql table like php? here an example in php
$data = "A,B,C,D";
$dataArray = explode(",",$data);
//then it will be like
//$dataArray[0] = "A";
//$dataArray[1] = "B";
//$dataArray[2] = "C";
//$dataArray[3] = "D";
this is because i want to put data in mysql in $data kind of format. when i want to do a search string, i will just 'explode' the data and do the necessary query.
the purpose i'm doing this is because i want to store few id in one single column. so when i want to search for a certain id, i will do something like above. i tried substring(), but those id might expand more and i have to edit my code.
eg:
myTable
|-----------------|
| mixedId |
|-----------------|
| 031290 |
|-----------------|
| 102234 |
|-----------------|
select mixedId from myTable where substring( mixedId, 3, 2 ) = '22'
the number you see in column mixedId represents few id. the first two digits are a foreign key lets say to table A, next two digits for table B and next two is for table C. those id are incremental numbers. what concerns me if one of the id will add up to 100, then the query result will be so messed up. so that's why i want to put a separator between those id and no mess will happen.
so got any explode for me?
thanx