select cwh ,aa from table1
 结果:
     cwh     aa
---------------------      d001   ''
      d002   ''
      d003   ''select jbh from table2
 结果:
     jbh    
---------------------      11001  
      11002  
      11003  如何用这两个表,使结果变成
     cwh     aa    jbh    
---------------------      d001   ''    11001
      d002   ''    11002
      d003   ''    11003

解决方案 »

  1.   

    select a.cwh ,a.aa b.jbh   from table1 a , table2 b
      

  2.   

    TO menggirl那样会造成笛卡尔乘积!!!!
      

  3.   

    select a.cwh ,a.aa ,b.jbh from table1 a,table2 b
    where right(a.cwh,3) = right(convert(varchar(20),b.jbh),3)
      

  4.   

    select a.cwh ,a.aa b.jbh   
    from table1 a 
    left join table2 b
    on substring(a.cwh,len(rtrim(a.cwh))-3,3)=substring(b.jbh,len(rtrim(b.jbh))-3,3)
      

  5.   

    select distinct(a.cwh) ,a.aa b.jbh   from table1 a , table2 b
      

  6.   

    select * from table1,table2
      

  7.   

    Database Server是? ↓Oracle SQLselect a.cwh ,a.aa ,b.jbh 
    from table1 a,table2 b
    where substr(a.cwh,2,3) = substr(b.jbh,3,3)
      

  8.   

    兄弟们。jbh  和CWH没有关系。jbh 是任意值呀。使用存储过程是肯定可以解决的。有没有什么方法可以直接把jbh接在 cwh,aa 后面的呢?
      

  9.   

    应该说:有没有什么SQL语句可以一下直接把jbh接在 cwh,aa 后面的呢?
      

  10.   

    jbh  和CWH没有关系 又怎能用SQL语句呢?须知SQL是用于关系试数据库的,!!!!!!
      

  11.   

    to :: huang_jihua(不懂...学习)  ,你看看 qinget 的留言,就知道你的方法行不行。