如题,有两个表a和b,在a和b之间做个查询,a表和b表中的id是一样的。
a表:id,istop
b表:id,username
想要查询的结果是:如果istop=true. 输出id,username

解决方案 »

  1.   


    select * from b where id in (select id from a where istop = true)
      

  2.   


    select a.id,a.username from [a] a
    left join b on a.id=b.id 
    where istop='true'
      

  3.   

    select a.id, b.username from a 
    left join b on b.id = a.id
    where a.istop = true
      

  4.   


    select b.id,b.username from b 
    left join a on a.id=b.id 
    where a.istop='true'
      

  5.   

    select a.id, b.username from a  ,b
    where a.istop = true and b.id=a.id
      

  6.   


    不好意思,少了个东东。a表:id,istop, hobby
    b表:id,username
    想要查询的结果是:如果istop=true. 输出id,username,hobby
      

  7.   

    inner join 就行了如题,有两个表a和b,在a和b之间做个查询,a表和b表中的id是一样的。
    a表:id,istop
    b表:id,username
    想要查询的结果是:如果istop=true. 输出id,usernameselect a.id,b.name from a inner join b on a.id=b.id where a.istop=true
      

  8.   

    select id,username from b where id in (select id from a where istop = true)
      

  9.   

    如果要输出 top (5)如何操作非常感谢
      

  10.   

    select top 5 id,username from b where id in (select id from a where istop = true)
      

  11.   

    select top 5 id,username from b where id in (select id from a where istop = true)
      

  12.   


       select top 5 a.id,b.name,a.hobby from a inner join b on a.id=b.id where a.istop=true