首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Informix >

informix涉及多表的查询。

2012-03-20 
informix涉及多表的查询。求救。-------------------------------------表1:t_tb1bdhxianzhong status000100

informix涉及多表的查询。求救。
-------------------------------------
表1:t_tb1
bdh xianzhong status
0001 001 3
---------------------------------------
表2:t_tb2
typecode code name
A01 001 A险种
A01 002 B险种
A01 003 C险种
B02 1 起始
B02 2 待审核
B02 3 已审核
-----------------------------------------
查询结果想要显示为下面的样子:(注:表1的数据量很)怎么实现
bdh xianzhong status
0001 A险种 已审核


[解决办法]
select a.bdh,b.name as xianzhong,c.name as status from t_tb1 a l
eft join t_tb2 bon a.xianzhong=b.code
left join t_tb2 c on a.status=c.code
[解决办法]
select 
t1.bdh bdh
(select name from t_tb2 t2 where t2.code = t1.xianzhong) xianzhong
(select name from t_tb2 t2 where t2.code = t1.status) status
form t_tb1 t1
where t1.bdh = '0001'
[解决办法]
楼主在哪家保险公司啊?也用informix?
用临时表过渡一下子可以不?

select code,name 
from t_tb2
where typecode = 'A01'
into temp jarod_1 with no log;

select code,name 
from t_tb2
where typecode = 'B02'
into temp jarod_2 with no log;

select a.bdh,b.name,c.name
from jarod_1 b,jarod_c, t_tb1 a
where a.xianzhong = b.code
and a.status = c.code;

不知道行不行,呵呵

热点排行