当前位置:首页 » 编程语言 » sql更新根据

sql更新根据

发布时间: 2022-07-31 02:39:08

sql如何根据B表内容更新A表.

试试看
用 B表中的数据 根据ID做group 求出最小的时间,而后在与B表关联查询获得最早的 开课时间的成绩
update A set A.chengji = (
select max(B.chengji) --防止重复 如重复取成绩最好的一个
from B, (select id,min(kaikeshijian) ktime from B group by id) t
where b.id = t.id and b.kaikeshijian = t.ktime and b.id = A.id
)

⑵ sql语句update select根据字段更新问题

1、tbl_cust_data_table_0000000298这个表没有field_50028161这个字段
2、你要更新的列有5个,而select出来的只有4个,不匹配

⑶ sql中根据不同条件更新不同表中的字段

没太明白你的需求

比如,这样?
搜索
update ta set col1 = (select case tb.a > 1000 then 1 else 0 end from tb where ta.id = tb.aid)
where ...

⑷ 求根据字段关联更新SQL语句

具体什么数据库

sqlserver:

updateaseta.bil_no=b.bil_nofroma,bwherea.src_itm=b.itmanda.src_itmin(selectitmfromb)

oracle:

updateaseta.bil_no=(selectb.bil_nofrombwherea.src_itm=b.itm)wherea.src_itmin(selectitmfromb)

mysql:

updateainnerjionbona.src_itm=b.itmseta.bil_no=b.bil_nowherea.src_itmin(selectitmfromb)

⑸ sql怎么根据其他表的字段更新数据

for SQL Server 数据库:
"update a set a.name=b.name1 from a,b where a.id=b.id"

以下在SQL Server中验证可行:
update a set a.status=b.status
from table1 a,table2 b
where a.id1=b.id1

⑹ SQL根据一张表的内容更新另一张表的某列

sqlserver:

updatet1sett1.D=t2.D
fromt2
wheret1.A=t2.A

Oracle:

updatet1setD=(selectt2.Dfromt2wheret1.A=t2.A)
whereexists(select1fromt2wheret1.A=t2.A)

⑺ 怎样写sql语句 同一表根据某字段相同就更新

update table
set name_id = (select distinct name_id from table t where t.name = table.name and t.name = 1)
where flag = 0

--当flag等于0的时候更新
--更新的值为:与当前name相同的,并且flag等于1的name_id

⑻ mysql如何根据一列值更新另一列的值

在更新表的使用where条件就行了,示例sql,
UPDATE aaa SET a1= a1/10000 WHERE a2= '万';
执行这条sql时,先将条件设置详细些,比如a2 = '万' and 主键 = 1 什么的,选择一条数据试试结果,确保不会因为误操作,将表中的数据修改。最好在修改数据前,将修改的数据找出来,执行一个备份。

⑼ sql一个表每日做更新。根据某一关键字段查找出修改的数据

IF Update(GroupJobNo)
begin
declare @OldNo nvarchar(30),@NewNo nvarchar(30)
select @OldNo=IsNull(GroupJobNo,'') from deleted
select @NewNo=IsNull(GroupJobNo,'') from Inserted

if (IsNull(@OldNo,'')<>'') and (IsNull(@OldNo,'')<>IsNull(@NewNo,''))
begin
update CT_Job set GroupJobNo=@NewNo where GroupJobNo=@OldNo
end
end;

⑽ sql查询 更新语句怎么写

1、首先需要打开sql server 数据库。

热点内容
pythonifthenelse 发布:2025-09-18 20:33:19 浏览:906
热血传奇脚本怎么做 发布:2025-09-18 20:29:06 浏览:604
轩逸手动经典有哪些配置 发布:2025-09-18 20:20:40 浏览:620
安卓手机下载软件在哪里设置密码 发布:2025-09-18 20:10:08 浏览:603
net业务缓存框架 发布:2025-09-18 19:57:14 浏览:10
pythonrst 发布:2025-09-18 19:28:50 浏览:408
页面访问在线升级 发布:2025-09-18 19:13:46 浏览:777
相机存储满 发布:2025-09-18 19:12:19 浏览:758
如何搭载我的世界服务器 发布:2025-09-18 19:02:39 浏览:431
c语言组框 发布:2025-09-18 19:02:23 浏览:947