select table_2.name from table_1,table_2 where table_2.type=table_1.type_1 or table_2.type=table_1.type_2 or table_2.type=table_1.type_3 and table_2.type in(1101,1102,1103);
select table_1.type_1 tp1,table_1.type_2 tp2,table_1.type_3 tp3,table_2.name name from table_1,table_2 where table_2.type=table_1.type_1 or table_2.type=table_1.type_2 or table_2.type=table_1.type_3 and table_2.type in(1101,1102,1103);
to: BlueskyWide(谈趣者)我是想在一条记录里同时有3个type的name,我要用他的name来代替他的代码. 还有,in(1101,1102,1103)的,1101,1102,1103有特殊的意义?
1101,1102,1103为你说的代码。 select table_2.type tp,nm1,nm2,nm3 from table_1,table_2 where (select name from table_1,table_2 where table_2.type=table_1.type_1) nm1 or (select name from table_1,table_2 where table_2.type=table_1.type_2) nm2 or (select name from table_1,table_2 where table_2.type=table_1.type_3) nm3;
oracle8i + windows server 2k 我写了一个很笨的方法select t1,t1name,t2,t2name,t3,tb2_3.name t3name from (select t1,t1name,t2,tb2_2.name t2name,t3 from (select type_1 t1,tb2_1.name t1name,type_2 t2 ,type_3 t3 from table_1,table_2 tb2_1 where table_1.type1=table_2.type ) , table_2 tb2_2 where t2 = tb2_2.type ) ,table_2 tb2_3 where t3 = tb2_3.type
可以再试试: select (select name from table_1,table_2 where type=type_1) nm1,(select name from table_1,table_2 where type=type_2) nm2,(select name from table_1,table_2 where type=type_3) nm3 from table_1,table_2 where type=type_1 or type=type_2 or type=type_3;
还有,in(1101,1102,1103)的,1101,1102,1103有特殊的意义?
select table_2.type tp,nm1,nm2,nm3 from table_1,table_2 where (select name from table_1,table_2 where table_2.type=table_1.type_1) nm1 or (select name from table_1,table_2 where table_2.type=table_1.type_2) nm2 or (select name from table_1,table_2 where table_2.type=table_1.type_3) nm3;
第 1 行: 'nm1' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,行 1
第 1 行: 'nm2' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,行 1
第 1 行: 'nm3' 附近有语法错误。
我写了一个很笨的方法select t1,t1name,t2,t2name,t3,tb2_3.name t3name
from (select t1,t1name,t2,tb2_2.name t2name,t3 from (select type_1 t1,tb2_1.name t1name,type_2 t2 ,type_3 t3 from table_1,table_2 tb2_1 where table_1.type1=table_2.type ) , table_2 tb2_2 where t2 = tb2_2.type ) ,table_2 tb2_3 where t3 = tb2_3.type
select (select name from table_1,table_2 where type=type_1) nm1,(select name from table_1,table_2 where type=type_2) nm2,(select name from table_1,table_2 where type=type_3) nm3
from table_1,table_2 where
type=type_1 or type=type_2 or type=type_3;