乍一看,这是我的查询
INSERT INTO T2
SELECT T1.*, T3.DATETIME, T3.STATEID
FROM T1 WHERE T3.DATETIME BETWEEN '01-NOV-15' AND SYSDATE
LEFT OUTER JOIN T3
ON (T1.DOCID = T3.DOCID);
T1
AND T2
在列数方面几乎相同;只有T2
有两列额外的(CREATIONDATE,STATEID)
T1
的每一行都需要插入T2
+另外两列CREATIONDATE & STATEID
中,这些列仅在T3
中可用。 T1
和'T3'都共享可用于加入它们的DOCID
...
仍有一些问题,非常感谢帮助。
获取错误
Error report -
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
答案 0 :(得分:2)
WHERE
子句位置的问题,必须在连接表列表之后:
INSERT INTO T2
SELECT T1.*, T3.DATETIME, T3.STATEID
FROM T1
LEFT OUTER JOIN T3
ON (T1.DOCID = T3.DOCID)
WHERE T3.DATETIME BETWEEN '01-NOV-15' AND SYSDATE;
答案 1 :(得分:2)
您的语法不正确,在连接之后出现:
INSERT INTO T2
SELECT T1.*, T3.DATETIME, T3.STATEID
FROM T1
LEFT OUTER JOIN T3
ON (T1.DOCID = T3.DOCID)
WHERE T3.DATETIME BETWEEN '01-NOV-15' AND SYSDATE