Sample Header Ad - 728x90

Insert rows into a table from another table row?

2 votes
1 answer
87 views
I've got a table **Schedule** |Id|unserId|Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday| |:----|:----|:----|:----|:----|:----|:----|:----|:----| |0|10|0|1|1|1|1|0|0| |1|20|1|0|0|0|0|0|0| I need to insert lines from ***one*** row in table **Schedule** into ***seven*** rows in table **Attending**, So the result would looks like this: |Id|userId|Day|Status| |:----|:----|:----|:----| |1|10|0|0| |2|10|1|1| |3|10|2|1| |4|10|3|1| |5|10|4|0| |6|10|6|0| |7|10|5|0| |8|20|0|1| |9|20|1|0| |10|20|2|0| To solve this, I think of using **Cursor**: I would use two cursors, one for each row in the table Schedule and the other for the 7 days of each row! Is it the right way of doing it, or there is a better way of doing it?
Asked by TAHER El Mehdi (292 rep)
Sep 29, 2022, 06:11 PM
Last activity: Sep 29, 2022, 09:19 PM