我有两个表table1,table2
里面分别有字段为
name,a1,a2,date
aa   1  1  2005-1-1
bb   2  1  2005-1-2
aa  1     2005-1-2
aa      1  2005-1-3name,b1,b2,date
aa   1  1  2005-1-1
bb
bb   1  2  2005-1-3
aa   1     2005-1-4现在我想用adoquery查询这两表中的aa,并在DBGrid上一齐显示,
如何在表中做到如下显示
name a1 a2 b1 b2 date
aa   1  1  1  1  2005-1-1
aa   1           2005-1-2
aa      1        2005-1-3
aa         1     2005-1-4
不知我说清楚了没有。

解决方案 »

  1.   

    select name ,a1,a2,b1,b2 [data] from table1,table2 where table1.data=table2.data and table1.name='aa' and table2.name='aa'机子上没有运行环境,你先试一下
      

  2.   

    select [table1].name,[table1].a1,[table1].a2,[table1].date,[table2].b1,[table2].b2 from table1,table2 where [table1].name=[table2].name and [table1].name='aa';
    我也是:机子上没有运行环境,你先试一下
      

  3.   

    我建了一个数据库如上所示:
    select c.name,c.a1,c.a2,d.b1,d.b2,c.date from table1 c,table2 d where c.date=d.date and c.name="aa" and d.name="aa"'
    结果:name a1 a2 b1 b2 date
          aa    1 1  1  1  2005-1-1
    这与我的结果不符呀。
      

  4.   

    使用 union all 就行了
      

  5.   

    to  kyee(浪子阿鹏):
    请详细讲一下,谢谢。