SELECT A.index , B.index
FROM DB.dbo.A, DB.dbo.B
Where A.index = B.index

解决方案 »

  1.   

    同库的话dbo可去掉
    SELECT A.index , B.index
    FROM A, B
    Where A.index = B.index
      

  2.   

    试试这个:
    SELECT A.*, (select count(*) from B where A.index = B.index) as 'b表中的条数'
    FROM A
      

  3.   

    select a.*,b.[条数] 
    from a inner join (select index,count(1) [条数] from b group by index) b on a.index=b.index
      

  4.   

    SELECT A.*, (select count(*) from B where A.index = B.index) as 'b表条数'
    FROM A
      

  5.   

    SELECT A.*,C.条数 FROM A JOIN (SELECT *,ROW_NUMBER() OVER(PARTITION BY B.ID ORDER BY B.ID)AS 条数 FROM B)C 
    ON A.INDEX=C.INDEX
      

  6.   


    select a.*,
           isnull(b.qty,0) 'qty'
     from 表A a
     left join (select [index],
                       count(1) 'qty' 
                from 表B 
                group by [index]) b on a.[index]=b.[index]
      

  7.   

    select a.* 
    from A a,B b
    where a.index = b.index