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
select id,username from b where id in (select id from a where istop = true)
如果要输出 top (5)如何操作非常感谢
select top 5 id,username from b where id in (select id from a where istop = true)
select top 5 id,username from b where id in (select id from a where istop = true)
select top 5 a.id,b.name,a.hobby from a inner join b on a.id=b.id where a.istop=true
select * from b where id in (select id from a where istop = true)
select a.id,a.username from [a] a
left join b on a.id=b.id
where istop='true'
left join b on b.id = a.id
where a.istop = true
select b.id,b.username from b
left join a on a.id=b.id
where a.istop='true'
where a.istop = true and b.id=a.id
不好意思,少了个东东。a表:id,istop, hobby
b表:id,username
想要查询的结果是:如果istop=true. 输出id,username,hobby
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
select top 5 a.id,b.name,a.hobby from a inner join b on a.id=b.id where a.istop=true