select t1.临时编号,t2.* from T1,T2
where t1.临时编号=2
and t1.编号=t2.编号
union all
select t1.临时编号,t2.* from T1,T3
where t1.临时编号=3
and t1.编号=t3.编号
union all
select t1.临时编号,t2.* from T1,T4
where t1.临时编号=4
and t1.编号=t4.编号
where t1.临时编号=2
and t1.编号=t2.编号
union all
select t1.临时编号,t2.* from T1,T3
where t1.临时编号=3
and t1.编号=t3.编号
union all
select t1.临时编号,t2.* from T1,T4
where t1.临时编号=4
and t1.编号=t4.编号
select t1.临时编号,t2.* from T1,T2
where t1.临时编号=@参数
and t1.编号=t2.编号
union all
select t1.临时编号,t2.* from T1,T3
where t1.临时编号=@参数
and t1.编号=t3.编号
union all
select t1.临时编号,t2.* from T1,T4
where t1.临时编号=@参数
and t1.编号=t4.编号
大力的更改为:
select A.字段 from (select 编号,姓名,成绩 from 表2 union all select * from 表3 union all select * from 表4) A join 表1 B on A.编号=B.编号 where B.临时编号=@参数
where A.col1 = '1'等同与select * from TableName
where TableName.col1 = '1'在以后调用就可以用别名A来代替表名了。