sql sever中插入一列已有的数据

new_tab表 和 final表在下面。现在要向final表中插入gread数据,这个数据来自于new_tab。要按照sno进行插入。我的语句是:insert into final(gread) select gread from new_tab where sno=final.s_no可是报错了: 无法绑定由多个部分组成的标识符 "final.s_no"。求解语句应该怎么写??
我去,我自己搞错了,应该是update:
update final set gread =(select gread from new_tab where sno=final.s_no)

第1个回答  2017-09-28
一、SQL中新增列或者说添加字段的语法:
alter table 表名 add 列名 数据类型
二、例如:在表texttable中添加一列字符型字段colnew:

1

alter table texttable add colnew char(20)

三、添加的新列,默认值为空值NULL。需要根据需求使用SQL语句更改
1、SQL修改列的语法:
update 表名 set 字段 = 赋值 where字句(确定要修改的列)
2、实例:

1
2

update texttable set colnew = 'temp';--把所有行的 colnew列的值改为 "temp"
update texttable set colnew = 'temp' where id=1000 ;--把ID为1000的行 colnew列的值改为 "temp"
第2个回答  2017-09-28
《相思》作者:王维
相似回答