有两张表
现在要更新t2中的file1字段,使 t2.file1的字段值 等于t1.id的值,其中t1和t2通过 t1.file2 和t2.file2相关联,t2的数据量要大于t1中的数据量,如果在t2中找不到对应的值,则不更新。
这个更新语句改怎么写?
t1 t2
id file2 file3 file1 file2
1 1 2 1 1
2 2 3 2 3
3 3 2 1 2
3 4
现在要更新t2中的file1字段,使 t2.file1的字段值 等于t1.id的值,其中t1和t2通过 t1.file2 和t2.file2相关联,t2的数据量要大于t1中的数据量,如果在t2中找不到对应的值,则不更新。
这个更新语句改怎么写?
t1 t2
id file2 file3 file1 file2
1 1 2 1 1
2 2 3 2 3
3 3 2 1 2
3 4
解决方案 »
- 【怎么样把sysdate插入到数据库中让数据库自动返行sysdate自动取服务器时间?】
- Oracle OEM无法连接数据库
- oracle还原库命令问题
- insert into 表(字段) select 字段 from 表,出现ORA-00997: illegal use of LONG datatype
- 不同库数据的比较
- oracle 10g linux 32bit 导出的文件 能导入 64bit的 oracle吗?
- 如何取得分组后每个分组的ROWNUM
- sqlplus /nolog 中的nolog表示什么意思?
- 请详细谈论"行锁","表锁"等等
- 如何查看rman所创建的脚本文件??
- 大家来帮我找个分页的BUG,找了一上午没找出来....谢谢哟.... 妈妈说标题要长..
- oracle Date
update t2 a set file1 = (select id from t1 where file2=a.file2) ;
where exists (select 1 from t1 b where b.file2=a.file2 and b.file1>a.file1 ) ;
where exists(select 1 from t1 c where a.filed2=c.filed2)
update t2 a set file1=(select id from t1 b where a.filed2=b.filed2 and rownum=1)
where exists(select 1 from t1 c where a.filed2=c.filed2)