I have 2 base tables TABLE_1 and TABLE_2. i want to derive a new table consisting ID of both table.
我有两个基表TABLE_1和TABLE_2。我想要导出一个包含两个表的ID的新表。
I NEED SQL QUERY TO CREATE THE THIRD TABLE CALLED NEW_TABLE in which ID_1 and ID_2 combines to form primary key. and if any of the ID in TABLE_1 or TABLE_2 is updated or deleted it should be reflected in NEW_TABLE also. eg:
我需要SQL查询来创建第三个表NEW_TABLE, ID_1和ID_2在其中结合形成主键。如果表_1或表_2中的任何ID被更新或删除,它也应该反映在NEW_TABLE中。例如:
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..:-)
请帮我……提前谢谢。:-)
4 个解决方案
#1
2
You can use SELECT INTO to select from some table(s) and insert the data into a new table.
您可以使用SELECT INTO从某些表中进行选择,并将数据插入到新的表中。
#2
1
you can use views for above case
您可以使用上述情况的视图
#3
1
Best way would be to use a view
最好的方法是使用视图
#4
0
Why dont you use just a query instead of table
为什么不使用查询而不是表呢?
SELECT
TABLE_1.ID,TABLE_2.ID
FROM TABLE_1,TABLE_2
#1
2
You can use SELECT INTO to select from some table(s) and insert the data into a new table.
您可以使用SELECT INTO从某些表中进行选择,并将数据插入到新的表中。
#2
1
you can use views for above case
您可以使用上述情况的视图
#3
1
Best way would be to use a view
最好的方法是使用视图
#4
0
Why dont you use just a query instead of table
为什么不使用查询而不是表呢?
SELECT
TABLE_1.ID,TABLE_2.ID
FROM TABLE_1,TABLE_2