0
votes

There is a task about sql. I have tree tables

Table_1

Id Name
1  Name1
2  Name2

Table_2

Id Name
3  Name3
4  Name4

And final table Table_3

Id Table1_Id  Table2_Id Value
1   1         3         Some Text
2   1         4         Some another text

So i would like two more rows to be generated for table_3

Id   Table1_Id  Table2_Id Value
1    1         3         Some Text
2    1         4         Some another text
null 2         3         null
null 2         4         null

How can i do this ? In fact, i have more then 5 tables with same signature as Table_1 and Table_2. And each time i add one row to the one of this table, the result Table_3's values count should be multiplied.

1

1 Answers

0
votes

Is Table_3 created from a JOIN of Table_1 and Table_2?

If so what JOIN are you using?

Have you tried CROSS APPLY or OUTER JOIN?