select b1.name as sd,b2.name as td,a.日期
from a,b b1,b b2
where a.sd=b1.code
and a.td=b2.code

解决方案 »

  1.   

    这样写,好理解些selcet (select name from B where code=A.SD) SD,(select name from B where code=A.TD) TD,,日期
    from A
      

  2.   

    笔误,更正select (select name from B where code=A.SD) SD,(select name from B where code=A.TD) TD,日期
    from A
      

  3.   

    下面我用表连接的写法,来给你回答这个问题
    select 'sd'=b1.name ,
           'td'=b2.name,
           a.日期
    from a join b b1
           on a.sd=b1.code
           join b b2
           on a.td=b2.code
    下面我用WHERE条件来回答这个问题
    select 'SD'=b1.name as,
           'TD'=b2.name as,a.日期
    from a,b b1,b b2
    where a.sd=b1.code
          and a.td=b2.code
    下面是用嵌套查询来解决这个问题
    select 'SD'=(select name from B where code=A.sd) ,
           'TD'=(select name from B where code=A.td) ,
            data
    from A
      

  4.   

    操作了一下有点问题
    现在写出操作没有问提的代码
    下面我用表连接的写法,来给你回答这个问题
    select 'sd'=b1.name ,
           'td'=b2.name,
           a.日期
    from a join b b1
           on a.sd=b1.code
           join b b2
           on a.td=b2.code
    下面我用WHERE条件来回答这个问题
    select 'SD'=b1.name,
           'TD'=b2.name,
           a.日期
    from a,b b1,b b2
    where a.sd=b1.code
          and a.td=b2.code
    下面是用嵌套查询来解决这个问题
    select 'SD'=(select name from B where code=A.sd) ,
           'TD'=(select name from B where code=A.td) ,
            日期
    from A