我有一个2表结构:
RID; Name; LP
E F 1
E F 2
E F 3
E F 12
E F 152
LP
1
2
3
12
152
...
156
157
180
itd.
查询类似:
Insert into TableA(RID, Name, LP) Values ('E', 'F', Select LP from TableB)
我想要实现:
RID; Name; LP
E F 1
E F 2
E F 3
E F 12
E F 152
E F 156
E F 157
E F 180
etc.
答案 0 :(得分:10)
你很亲密。尝试
INSERT INTO TableA(RID, Name, LP)
SELECT 'E', 'F', LP FROM TableB
-- Omit this where clause, if duplicate LP's are OK
WHERE TableB.LP NOT IN (SELECT LP FROM TableA)
答案 1 :(得分:1)
Insert into TableA(RID, Name, LP)
Select
'E', 'F', LP
from
TableB
答案 2 :(得分:0)
我提出的“快速而肮脏”的解决方案是:
Insert into TableA(RID, Name, LP) Values ('E', 'F', Select LP from TableB where rowid = 1)
Insert into TableA(RID, Name, LP) Values ('E', 'F', Select LP from TableB where rowid = 2)
...
依旧......
答案 3 :(得分:0)
从[OLD_TABLE]
中选择*进入[NEW_TABLE]享受。