sql 导数据语句怎么写?

来源:百度知道 编辑:UC知道 时间:2024/05/27 00:08:54
有 Ta 和 Tb 两个表。
Ta 的字段是:t1,t2;
Tb 的字段是:t2,t3。
请问用 sql 语句怎么写:
将 Ta(t2) 的数据导入到 Tb(t2) 里面!

用 INSERT INTO ... SELECT ... 可以将其它表的数据插入表中
insert into tb(t2) select ta.t2 from ta

insert into ta value select * from tb

mysql:

insert into Tb (t2) select t2 from Ta

=====我是华丽的分割线===========

你可以在mysql里面找到这个文档:

1.9.5.2. SELECT INTO TABLE
MySQL Server doesn't support the SELECT ... INTO TABLE Sybase SQL extension. Instead, MySQL Server supports the INSERT INTO ... SELECT standard SQL syntax, which is basically the same thing. See Section 13.2.4.1, “INSERT ... SELECT Syntax”. For example:

INSERT INTO tbl_temp2 (fld_id)
SELECT tbl_temp1.fld_order_id
FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;
Alternatively, you can use SELECT ... INTO OUTFILE or CREATE TABLE ... SELECT.

As of MySQL 5.0, you can use SELECT ... INTO with user-defined variables. The same syntax can also be used inside stored routines using cursors and local variables. See Section 17.2.7.3, “SELECT