I’m trying to normalize a mysql database….
I currently have a table that contains 11 columns for “categories”. The first column is a user_id and the other 10 are category_id_1 – category_id_10. Some rows may only contain a category_id up to category_id_1 and the rest might be NULL.
I then have a table that has 2 columns, user_id and category_id…
What is the best way to transfer all of the data into separate rows in table 2 without adding a row for columns that are NULL in table 1?
thanks!
You can create a single query to do all the work, it just takes a bit of copy and pasting, and adjusting the column name:
Since you only have to do this 10 times, and you can throw the code away when you are finished, I would think that this is the easiest way.