A, B, C 三个表。select colum form A;if (colum = 0) {       select * from A,B where A..xx = B.xx .......} else  {        select * from A,C where A..xx = C.xx .......
}请问以上的 所有sql,能不能用一个sql 搞定?各位大虾帮帮忙,不然明天就下岗了。谢谢。

解决方案 »

  1.   

    首先:select colum form A;不能与下面2个带select * ...的sql写到一起,因为字段个数不同。下2个sql比较容易,在2个sql中追加2个完全不同的条件,之后union:select * from A,B where A..xx = B.xx ....... 
     and A.colum =0unionselect * from A,C where A..xx = C.xx .......
      and A.colum <>0