Skip to content
Advertisement

How to copy from Parent table to Child Table with 1 column dividing into 3 different column

I have a table column like following

Now I want to Divide this column into 3 columns like as

How will the SQL Query for this?

Advertisement

Answer

On MySQL 8+, you could use ROW_NUMBER for this purpose:

screen capture from demo link below

Demo

This approach has an advantage over a union in that it can easily be extended to support more rows and columns as you need.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement