如果有n多个select 从多个表种选出了n多个字段,我将这些字段都按照上面的 形式按列组合起来,如果是行的话我知道是用union all 但是列就是不知道。 麻烦各位了
发表于:2007-04-27 16:08:501楼 得分:20
select table1.*,table2.* from table1,table2 where table1.id=table2.id
发表于:2007-04-27 16:22:092楼 得分:0
没有楼上的那么简单 因为实际操作的时候 一条select 语句需要关联很多个表 比如说 select b.data2/1000 from profit a left join profit_item b on a.id=b.profit where a.enterprise=@enterprise and a.report_y=@dty and a.report_m=@dtm and a.audit> 0 and b.pid=1 ----这选出了第一个字段---- select b.data2/1000 from profit a left join profit_item b on a.id=b.profit where a.enterprise=@enterprise and a.report_y=@dty and a.report_m=@dtm and a.audit> 0 and b.pid=2 ----这选出了第二个字段---- . . . . . . . 以上select 算是比较简单的了。有很多复杂的select,我想把每个select 选出的值拼装成 (每个select只选择一行记录),然后再用union all 拼装成一个多行记录集的表