【问题标题】:Insert values from two tables into a third table [closed]将两个表中的值插入第三个表[关闭]
【发布时间】:2013-07-26 17:03:02
【问题描述】:

我有一张桌子t1(id) 和一张桌子t2(did, ddept, dname)。我想插入表格 t3(id 来自 t1did,ddept,dname 来自 t2)。我完全被困在这个问题上,需要一些帮助。

【问题讨论】:

  • t1 和 t2 表之间有关系吗?
  • 在 t1 和 t2 之间没有关系

标签: oracle oracle11g


【解决方案1】:
Insert into t3 (Select t1.id, t2.did, t2.ddept, d2.dname from t1 cross join t2)

但是,在不知道 t1 和 t2 如何关联的情况下,您会得到笛卡尔结果。还假设 T3 中的列顺序是 T1.ID、t2.did、t2.ddept 和 d.name...

找到的上一篇文章 :INSERT SELECT statement in Oracle 11G 展示了如果订单不匹配如何进行正确的格式化。

【讨论】:

    猜你喜欢
    • 2018-03-23
    • 1970-01-01
    • 1970-01-01
    • 2021-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多