现在有一张表,字段如下:
id name parent_name parent_id
001 jack tom
002 tom
数据库现在id、name、parent_name都已经有数据了,但是parent_id还没有,
请问如何用一个update语句,查到parent_id并补上?(就是update上面第一行的parent_id为002).希望各位高手指教!数据库update
id name parent_name parent_id
001 jack tom
002 tom
数据库现在id、name、parent_name都已经有数据了,但是parent_id还没有,
请问如何用一个update语句,查到parent_id并补上?(就是update上面第一行的parent_id为002).希望各位高手指教!数据库update
解决方案 »
- 急问ORACLE数据库同步的方法步骤!
- 一条简单的sql语句
- 大家好,关于Oracle中系统权限unlimited tablespace授予给自己创建的角色问题?
- WIN2003安装完ORACLE 9i以后,必须手工设置环境变量吗?
- 尝试做一个从外部数据库导入本数据库的功能!麻烦各高手帮忙一下
- Oracle9i的服务器端和客户端可以装在同一台机子吗?
- 动态CURSOR问题
- 请问一个Sql语句的问题
- 什麼情況下select要求寫into語句???怎麼我的procedure老是提示我要寫into子句
- 大家用oracle做web数据库 都用接口什么访问数据
- oracle 更新语句死锁问题?????
- 查询不到数据时设一个默认值
update table set parent_id=id where parent_id is null;
这个意思吗?
update table set parent_id=id where parent_name in(
select parent_name from table where parent_name ||parent_id is not null
)
这个意思吗?
update table set parent_id=id where parent_name in(
select parent_name from table where parent_name ||parent_id is not null
)
不是,就比如jack的父亲是tom,然后现在需要找到tom的id(就是002),填到jack的parent_id上
update t1
set parent_id= (select id from t1 t where t.name = t1.parent_name)
where parent_id is null and parent_name is not null