我在原理图中看到了两张桌子。我想要复制URI
中三列fields
,details
和table1
的数据,如果table2
中的日期更长,则将其插入table1
比12/11/2013。像下面的查询:
INSERT INTO table2 (all_links, fields_one, fields_two)
FROM table1 (URI, fields, details) WHERE date>"12-11-2013 00-00-00";
您能帮忙解决这个问题吗?
答案 0 :(得分:2)
喜欢
INSERT INTO table2 (all_links, fields_one, fields_two)
select URI, fields, details FROM table1
WHERE date > "12-11-2013 00-00-00";
如果表位于不同的DB中(假设dbo
是默认所有者)
INSERT INTO DB1.dbo.table2 (all_links, fields_one, fields_two)
select URI, fields, details FROM DB2.dbo.table1
WHERE date > "12-11-2013 00-00-00";
答案 1 :(得分:1)
尝试这样的事情:
INSERT INTO tbl_temp2 (fld_id)
SELECT tbl_temp1.fld_order_id
FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
并查看文档:
答案 2 :(得分:1)
INSERT INTO table2 (all_links, fields_one, fields_two) select URI, fields, details from table1 where date>"12-11-2013 00-00-00";