update b
set
qh=(select a.qh from a where a.qh=substr(b.tel,1,3))
dq=(select a.dq from a where a.qh=substr(b.tel,1,3))
where exist(select 1 from a,b where a.qh=substr(b.tel,1,3))
set
qh=(select a.qh from a where a.qh=substr(b.tel,1,3))
dq=(select a.dq from a where a.qh=substr(b.tel,1,3))
where exist(select 1 from a,b where a.qh=substr(b.tel,1,3))
解决方案 »
- 关于oracle中的commit
- 使用insert 触发器,如何只触发而不插入
- 如何创建存储过程
- ORA-24960:属性OCI_ATTR_USERNAME 的长度大于最大允许长度255
- 如何知道blob字段是否被修改过?
- 关于一个触发器的问题分不多了出50
- 请问:oracle中怎么查询上次插入数据后该表中加入数据的行数?谢谢
- 大家能谈一谈(+) 在SQL中的运用
- 迷惹:select ...start with ... connect by,这个sql语句如何用,它表示什么意思
- oracle11奇怪的问题:连接不上远程的数据库,但本地的可以连。。
- 谁来帮我解决一道买试试题?
- (急)developer2000报表中某些字段出现乱码,怎么会事?
select qh,dq
from a
where a.qh=substr(b.tel,1,3)
这个sql仍有些问题,不能处理非3位的区号
如果表a,b都多一条记录qh='023X',处理起来会比较麻烦
set (qh,dq)=(select a.qh,a.dq from a where b.tel like a.qh || '%')
where exist(select 1 from a where b.tel like a.qh || '%')
有前途!
1.现对数据进行规范化处理;2.然后用
update b set (qh,dq)=(
select qh,dq
from a
where a.qh=substr(b.tel,1,3);进行更新!
你说得有道理 我也查了 确实是这样
To: fffddd (杀我者死)
这个sql改为
update b set (qh,dq)=
(
select qh,dq
from a
where length(a.qh)=3 and a.qh=substr(b.tel,1,3)
or length(a.qh)=4 and a.qh=substr(b.tel,1,4)
)
即可!!
(
select qh,dq
from a
where a.qh=substr(b.b.tel,1,length(a.qh))
)
(
select max(qh),dq
from a
where a.qh=substr(b.b.tel,1,length(a.qh))
group by dq
)
就这样就可以了 比我的简洁多了
既然,你的区号都是三位的,那你在入数据库的时候,完全可以把它进行一个匹配
如果,少了,就进行加0补充位数
当然 ouygg(痞子酷) 的办法的确也是解决的办法之一
不过,这不是解决根本的方法哟 !