select * from table1,table2
where table1.field1*=table2.field1
union 
select * from table1,table2
where table1.field1=*table2.field1

解决方案 »

  1.   

    select * from table1,table2
    where table1.field1*=*table2.field1
      

  2.   

    可以这样:
     假使字段前四个部分完整select * from table1 LEFT JOIN table2 on substring(table1.field1,1,4)=substring(table2.field2,1,4) where ....
      

  3.   

    同意leeyoong(莫西)。只是这样的表结构太可怕,用union效率很低,不得已才用之
      

  4.   

    在sqlserver中可以使用全连接
    select t1.*,t2.* from table1 t1 full join table2 t2 on t1.id=t2.id
      

  5.   

    select * from table1,table2
    where table1.field1*=table2.field1
    union 
    select * from table1,table2
    where table1.field1=*table2.field1 
      

  6.   

    *=确实不好,而且会被淘汰(MS 说的)。
    smartdonkey(聪明的毛驴) 说的对,用全连接。