select B.clo2, table1.clo2 , table2.clo2 from A
left outer join B on A.clo1 = B.clo1
left outer join B As table1 on A.clo1 = table1.clo1
left outer join B As table2 on A.clo1 = table2.clo1
就可以了
left outer join B on A.clo1 = B.clo1
left outer join B As table1 on A.clo1 = table1.clo1
left outer join B As table2 on A.clo1 = table2.clo1
就可以了
只是稍稍改一下
...
left outer join B As table1 on A.clo2 = table1.clo1
left outer join B As table2 on A.clo3 = table2.clo1
B as C, B as D, B as E
where A.clo1 = C.值字段
and A.clo1 = D.值字段
and A.clo1 = E.值字段
B as C, B as D, B as E
where A.clo1 = C.值字段
and A.clo2 = D.值字段
and A.clo3 = E.值字段
select
case clo1 when '0' then '正常' when '1' then '不正常' when '2' then '故障' end as clo1,
case clo2 when '0' then '正常' when '1' then '不正常' when '2' then '故障' end as clo2,
case clo3 when '0' then '正常' when '1' then '不正常' when '2' then '故障' end as clo3
from a如果要是经常改动二表的话,用动态SQL或者上面说的表连接也可以!
(select decr from b where val=c.clo1) as clo1,
(select decr from b where val=c.clo2) as clo2,
(select decr from b where val=c.clo3) as clo3
from a c
这样也行!
select @s = '正常 不正常故障 '
select substring (@s,col1 *3,3),substring (@s,col2*3,3),substring (@s,col3*3,3) from A好像substring是这样写的吧,中文是1还是2个char啊
faint
太久没有用了,全当是1个char,如果不是自己乘以2吧
自己看看吧:)