table1
----------
userid state date
100 a 2010-03-20
101 b 2010-03-20
102 a 2010-03-20
-------
table2
--------
userid state
101 a
102 b
-----
table1执行UPDATE结果为
--------
userid state date
100 a 2010-03-20
101 a 2010-03-20
102 b 2010-03-20用UPDATE语句可以一次执行么?
----------
userid state date
100 a 2010-03-20
101 b 2010-03-20
102 a 2010-03-20
-------
table2
--------
userid state
101 a
102 b
-----
table1执行UPDATE结果为
--------
userid state date
100 a 2010-03-20
101 a 2010-03-20
102 b 2010-03-20用UPDATE语句可以一次执行么?
解决方案 »
- java连接oracle11g数据库,菜鸟怎么也连不上,跪求连接方法,求代码,求jar包导入位置,代码能实现select *from emp的功能
- oracle如何分配这样的权限
- sql语句优化问题求教
- LINUX ORACLE 10g 数据库备份
- oracle导入问题
- 在只有oracle10g数据查询权限的情况下,能自已写函数并执行吗?
- 在线急求存储过程
- 请指点指点我--寻找数据库优秀读物
- 向oracle8i导入ACCESS2003表格数据的问题(在线等!!!)
- substr(IngestTime,1,10) as date 这句SQL为什么不行呢?
- 求救!!!请高手帮我这句话什么意思?
- 两道sql题
set state=(select b.state from table2 b where a.userid=b.userid)
where exists (select 1 from table2 b where a.userid=b.userid)
UPDATE table1 a
SET state =
(SELECT state FROM table2 t WHERE t.userid = a.userid)
WHERE a.userid IN (SELECT userid FROM tables);--方法2
UPDATE table1 a
SET state =
(SELECT state FROM table2 t WHERE t.userid = a.userid)
WHERE EXISTS (SELECT 1 FROM table2 t WHERE t.userid = a.userid);
--方法1
UPDATE table1 a
SET state =
(SELECT state FROM table2 t WHERE t.userid = a.userid)
WHERE a.userid IN (SELECT userid FROM table2);--方法2
UPDATE table1 a
SET state =
(SELECT state FROM table2 t WHERE t.userid = a.userid)
WHERE EXISTS (SELECT 1 FROM table2 t WHERE t.userid = a.userid);