I have a comma delimited string held within a database field that could contain any number of values:
I need to be able to somehow switch two values, so for example I know I need to move 45 one position down the string, so I end up with:
The reason for this is that the numbers all correspond to the IDs held in another database table, and their position in the sting determine the order those items will be printed on screen. Before you ask about database design - I've inherited it and it cannot be changed without significant work to an entire application.
So I've thought about exploding the string, identifying the position of the target number and swapping it with the one next-door, but I'm unsure of how this can be achieved when the total number of values is not known.
Any things? I suspect the solution will be cumbersome, but needs must!!