I have following tables in my application:
Table-1
--------------------------------------
| id | column_2(array_type) |
--------------------------------------
| 1 | [20,21,22] |
--------------------------------------
Table-2
---------------------------------------
| id | column_2(array_type) |
---------------------------------------
| 3 | [31,32] |
---------------------------------------
Now I want to create a view as follows:
-----------------------------------------------------------------
| id | Table_1_id | Table_2_id | column_2 |
-----------------------------------------------------------------
| 1 | 1 | nil | 20 |
-----------------------------------------------------------------
| 2 | 1 | nil | 21 |
-----------------------------------------------------------------
| 3 | 1 | nil | 22 |
-----------------------------------------------------------------
| 4 | nil | 3 | 31 |
-----------------------------------------------------------------
| 5 | nil | 3 | 32 |
-----------------------------------------------------------------
The view should have single row entry for every item in column_2
'.
Am unable to split the column_2
's array content to individual row and assign corresponding table's
id to it.
Any help or reference would be very helpful. I do not have much experience with SQL.
Couldn't find much on this in google.