I’ve been trying to figure this problem out for a while now. Hope anyone can help here please.
I have an semicolon separated CategoryIDs in my Article table (e.g. ;2;34;5;9;), and I have a Category table with the old CategoryID column and the new CategoryID column. Now I’d like to update the CategoryIDs in the Article table with some new CategoryID based on the original CategoryIDs. e.g. (e.g. ;2;34;5;9;) will be updated to (e.g. ;564;344;753;944;)
The reason that I need this is because I’m merging tables from two databases with the same tables set ups.
I know this is a bad design, but it’s been like this for ages. I can’t really think of a solution for this, any help would be really appreciated.
Yes it is a bad design.
I suppose you use MySQL. I’ve used GROUP_CONCAT MySQL featured function but you can emulate it in MSSQL also. And I suppose you need to replace ALL old Id’s with new.
SQLFiddle demo
Tables:
and update to replace groups: