在SqlServer里的一个数据库里有三个表, A, B , C 表结构字段都一样的!
我怎样实现查询这三个表的数据在同一个DBGrid里显示!!
SELECT A.*, B.*
FROM A, B
这样查的结果不对, 有六万多数据, 我本来两个变加起来才有一两千数据??
表都没有关联关系!

解决方案 »

  1.   

    select * from A
    union all
    select * from B
    union all
    select * from C
      

  2.   

    SELECT * FROM A 
    union all
    SELECT * FROM B 
    union all
    SELECT * FROM C
      

  3.   

    SELECT A.*, B.*
    FROM A, B
    where a.id=b.id
    and a.*=b.*
      

  4.   

    select * from A
    union all
    select * from B
    union all
    select * from C
      

  5.   

    应该用联合而不是连接,Use UNION/UNION ALLSELECT * FROM A UNION ALL SELECT * FROM B UNION ALL ...UNION ALL SELECT * FROM N
      

  6.   

    怎么给分啊、?在问一下, 
    视图里面不可以用
    select * from A
    union all
    select * from B
    union all
    select * from C提示
    查询设计器不支持 UNION SQL 构造
      

  7.   

    select *
    from A 
    union all 
    select * 
    from B
    union all 
    select *
    from C
      

  8.   

    create table A(name int)
    create table B(name int)
    create table C(name int)
    gocreate view tt as 
    select * from A
    union all
    select * from B
    union all
    select * from C
    goselect * from tt
    drop view tt
    drop table A
    drop table B
    drop table C
    --没问题阿.
      

  9.   

    select * from a
    union 
    select * from b
    union 
    select * from c
      

  10.   

    AJLW(AJ) ( ) 信誉:100  2006-04-07 14:57:00  得分: 0  
     
     
       怎么给分啊、?在问一下, 
    视图里面不可以用
    select * from A
    union all
    select * from B
    union all
    select * from C提示
    查询设计器不支持 UNION SQL 构造
      
     
    select * from
    (select * from A
    union all
    select * from B
    union all
    select * from C) dd这样看下