oracle表中多个字段同时和另一个表中关联,如何处理

时间:2021-09-29 14:57:20
我的Oracle有个表a 由三个字段jiebie1,jiebie2,jiebie3, 还有等级表b
表a
  jiebie1,jibie2,jibie3
   1         2      3
表b 

    dengji    mingcheng
    0             不称职
    1             基本称职
    2              称职
    3            优秀
    -1          <未设置>
也就是要实现当表a jiebie1,jiebie2,jiebie3,对应值不同时,如何显示b表中所对应的名称   
   

3 个解决方案

#1


select b1.mingcheng ,b2.mingcheng ,b3.mingcheng 
from a,b b1,b b2, b3
where a.jiebie1=b1.dengji
and a.jiebie2=b2.dengji
and a.jiebie3=b3.dengji

#2


把b表重命名当3个表用
select b1.mingcheng ,b2.mingcheng ,b3.mingcheng 
from a,b b1,b b2,b b3
where a.jiebie1=b1.dengji
and a.jiebie2=b2.dengji
and a.jiebie3=b3.dengji


#3


呵呵呵,郁闷半天没思路,数据库学的太差,没想到这么快就有回复,试了下,可以,谢谢啦,给分

#1


select b1.mingcheng ,b2.mingcheng ,b3.mingcheng 
from a,b b1,b b2, b3
where a.jiebie1=b1.dengji
and a.jiebie2=b2.dengji
and a.jiebie3=b3.dengji

#2


把b表重命名当3个表用
select b1.mingcheng ,b2.mingcheng ,b3.mingcheng 
from a,b b1,b b2,b b3
where a.jiebie1=b1.dengji
and a.jiebie2=b2.dengji
and a.jiebie3=b3.dengji


#3


呵呵呵,郁闷半天没思路,数据库学的太差,没想到这么快就有回复,试了下,可以,谢谢啦,给分