问题描述
- 怎么 同时把数据库中 一个表的多条数据的一个自段修改,
-
数据库表 ,student , 字段 stu_id, stu_name,Stu_num,Stu_sex,
表 import , 字段, stu_id, import_id, imp_data, imp_name, 在查出两个表关联信息的时候,怎么把imprt表中的imp_data 字段改为系统当前时间update import set imp_data =sysdata where stu_id in (select stu_id from import)这样好像不对,知道的哥哥姐姐,请告知,关于 ,oracle update,和select in 语句
解决方案
访问另一个数据库的表数据
数据库中把数据从一个表中插入到另一张表中
遍历查询一个数据库中所有表,列出表名和每个表中的数据行数
解决方案二:
select stu_id from import是查出import表中的所有stu_id字段值。
where stu_id in (...)就是stu_id在查出的结果集中。
同样都是import表,你这个条件写了和没写都是一样的效果,都是全表更新。
在in条件里 你把需要修改时间的记录的stu_id根据条件找出来就行了,前面的不变
解决方案三:
update import set imp_data =sysdata where stu_id in (select stu_id from student)
就是in里面的from表你写错了,应该是student
解决方案四:
update imprt set imp_data= now() where stu_id in(
select stu_id from student where ...
)
解决方案五:
update import set imp_data =sysdata where stu_id in (select stu_id from stddent)
或者
update import set imp_data =sysdata where exists (select 1 from import where stu_id = import.stu_id)