How to create a view from two other tables?

I have 2 base tables TABLE_1 and TABLE_2. I want to get a new table consisting of the identifier of both tables.

I NEED SQL QUERY TO CREATE THE THIRD TABLE CALLED BY NEW_TABLE, in which ID_1 and ID_2 are combined to form the primary key. and if any of the IDs in TABLE_1 or TABLE_2 is updated or deleted, it should also be reflected in NEW_TABLE. eg:

TABLE_1          TABLE_2
ID    XXX        ID     ZZZ
100   A          200     P
101   B          201     Q  
102   N          202     R 
103   F          203     S

NEW_TABLE
ID_1   ID_2
100    200
100    201
100    203
101    200
101    202
103    200
103    201
103    203   

PLEASE HELP ME ...... thanks in advance .. :-)

+3
source share
4 answers

You can use SELECT INTO to select from some table (s) and insert data into a new table.

+2
source

you can use representations for the above case

+1

-

+1

SELECT
TABLE_1.ID,TABLE_2.ID
FROM TABLE_1,TABLE_2
0

All Articles