奥礼网
新记
sql insert into 命令的使用 我想在表1的特定3行中插入数据,数据在表2里边请问命令如何写?
我需要把表2的1、2列插入到表1的a.b列前提是表2的b列不为空便插入表一同时表一的c列替换为111
举报该文章
相关建议 2012-01-01
设定table1的字段是a,b,c,table2的字段是c,d,e,table1和table2的对应字段类型一致,不然需要转换类型,当然这两张表的字段也可以更多,
只要将你要处理的字段分别替换成设定的字段就行。
insert into table1(a,b,c)
select c, d, 111
from table2
where d is not null
温馨提示:内容为网友见解,仅供参考
当前网址:
https://aolonic.com/aa/kgd4g3ak3.html
其他看法
第1个回答 2011-12-23
--这样?
insert into table1(column1, column2, column3...)
select 1, b.column1, b.column2...
from table2 as b
第2个回答 2011-12-23
直接使c列是'111' 是吧?是varchar类型吗?这是思路,你试一下
insert into t1 (
select t2.*,'111' c from t2 where b is not null and rownum < 3 );
第3个回答 2011-12-23
同楼上,不过得确认你的这三列外的值可以为空或者有默认值才可以这样插数据。as b类似同义词,将table2同义为b
相似回答
大家正在搜
相关问题
我想在SQL表中插入一条数据,请问SQL语句应该怎么写
向数据表中插入记录的T-SQL语句是什么
在sql中,原始表中有数据,想再插入新数据?
如何将A表中的数据插入到B表,而且不重复插入?
请问sql server中如何把一张表的一列数据按顺序插入到...
请教可以只用一句sql insert into 同时往数据库...
sql怎么删除一个表中的所有数据
请问如何在SQL数据库中使用命令导出excel文件?