从oracle转过来的select * from t,b where t.id=b.id(+) and b.name(+)='hanjs'这样怎么转过来?select * from t left join b on t.id=b.id 后面要怎么写啊?是否等价于这样?
select * from t left join (select * from b where name='hanjs') b on t.id=b.id

解决方案 »

  1.   

    select * from t left join b on t.id=b.id  and b.name = 'hanjs'
      

  2.   

    是否等价于这样?select * from t left join (select * from b where name='hanjs') b on t.id=b.id
    --對
      

  3.   

    select * from t,b where t.id=b.id and b.name ='hanjs' 
      

  4.   

    select * from t left join b on t.id=b.id and b.name='hanjs'
    或者
    select * from t left join b on t.id=b.id where b.name='hanjs'
      

  5.   

    if object_id('t') is not null drop table t
    go
    if object_id('b') is not null drop table b
    go
    create table t(id int not null,class varchar(10))
    create table b(id int not null,name varchar(10))insert into t values (1,'计算机')
    insert into t values (2,'英语')insert into b values (1,'hanjs')
    insert into b values (3,'zhaos')--验证1楼
    select * from t left join b on t.id=b.id and b.name = 'hanjs'
    /*
    1 计算机 1 hanjs
    2 英语 NULL NULL
    */
    --验证2楼
    select * from t left join (select * from b where name='hanjs') b on t.id=b.id 
    /*
    1 计算机 1 hanjs
    2 英语 NULL NULL
    */
    --验证3楼
    select * from t,b where t.id=b.id and b.name ='hanjs' 
    /*
    1 计算机 1 hanjs
    */
    --验证4楼
    select * from t left join b on t.id=b.id and b.name='hanjs' --已验证select * from t left join b on t.id=b.id where b.name='hanjs'
    /*
    1 计算机 1 hanjs
    */经过上面测试,大家应该知道那个对了