扶摇皇后小说落霞:如何时用SQL select命令 把一个库的某个字段的内容加入到另一个库里
来源:百度文库 编辑:神马品牌网 时间:2024/10/07 17:15:29
可用:
use 要写入的数据库名
insert into 目标表 (字段名1,字段名2,……) (select 字段名1,字段名2,…… from 数据源库名..数据源表名 where 条件)
如果目标表内的字段与源表的中的字段不同可用以下命令格式:
第一步:select 字段名 as 目标字段名 into #临时表名 from 数据源库名..源表名 wehre 条件
第二步:update 目标表名 set 目标字段名=#临时表相同字段名 from #临时表名 a,目标表名 b where 条件
如:假设有A库和B库,要将A库A1表中的id字段的数据写入到B库B1表中的id字段。可用: 第一种
use B
insert into B1 (id) (select id from A..A1 where 条件)
第二种 B库B1表中的字段不是id,而是id2
use B
select id as id2 into #临时表名 from A..A1 where 条件
update B1 set b.id2=a.id2 from #临时表名 a,B1 b where 条件
update 表2
set 字段2=(select 字段1 from 表1 where .....)
where (.....)
select 字段1 from 表1 where ..... 选出要添加的字段的内容
where (.....) 选出要添加的位置
如何时用SQL select命令 把一个库的某个字段的内容加入到另一个库里
SQL 用select 语句,怎么样把重复的数据去掉?
比较用SELECT-SQL命令查询与用查询设计器建立查询不同的特点?
一个SQL命令
我在ORACLE中建立了一个表为什么等我把SQL*PLUS关闭之后再打开用SELECT搜索就找不到记录了呢
select是SQL的命令。那么exec和declare命令都是哪里的知识
vfp中select 命令怎么用?
请问sql语句中要把一个查询存在一个文件中,命令该怎么写
利用SQL select 命令将表stock_sl.dbf 复制到 stock_bk.dbf
利用SQL select 命令将表stock_sl.dbf 复制到 stock_bk.dbf