SQL表中列与列的运算如何实现?请各位大虾帮忙~

2025-03-04 21:33:05
推荐回答(5个)
回答1:

假定数据库字段为

id,name,color,kc,ch

select id,name,color,kc,ch,kc-ch as jc from table order by id 即可.

回答2:

在T-Sql中可以直接进行运算操作。如:
select jc=kc-ch from table where id='3'

回答3:

update table1 set jc=kc-ch

执行这个 就行了

回答4:

可用触发器
or
计算列

如新增列jc:
alter table t add jc as kc-ck

回答5:

SQL Server数据中运算符与表达式