I need to perform update/insert simultaneously changing structure of incoming data.
Think about Shops that have defined work time for each day of the week.
Hopefully, this might explain better what I'm trying to achieve:
worktimeOrigin table:
columns:
- shop_id
- day
- val
data:
shop_id | day | val
------------------------------
123 | "monday" | "9:00 AM - 18:00"
123 | "tuesday" | "9:00 AM - 18:00"
123 | "wednesday" | "9:00 AM - 18:00"
shop table:
columns:
- id
- worktimeDestination.id
worktimeDestination table:
columns:
- id
- monday
- tuesday
- wednesday
My aim:
I would like to insert data from worktimeOrigin table into worktimeDestination and specify appropriate worktimeDestination for shop.
shop table data:
- 123
- 1 (updated)
worktimeDestination table data:
id | monday | tuesday | wednesday
---------------------------------------------------------------------------
1 | "9:00 AM - 18:00" | "9:00 AM - 18:00" | "9:00 AM - 18:00" (inserted)
Any ideas how to do that?