各位高手:我有两个表结构如下: 
     表一:  ID  date1  date2  date3 date4
              1     12    23     21    25
              1     21    21     26    14
              2     52    12     41    23
              2     21    45     41    21
     表二:  ID          datetime
              1      2012-2-6  12:23:02
              2      2012-2-7  12:12:21
其中两个表的ID是是相互关联的,即一个ID对应的一个时间。
我想在dataGridView里显示的效果如下:
             ID    date1   date2   date3   date4        datetime
              1      12     23      21     25      2012-2-6  12:23:02
              1      21     21      26     14      2012-2-6  12:23:02
              2      52     12      41     23      2012-2-7  12:12:21
              2      21     45      41     21      2012-2-7  12:12:21
请问该如何做呢?谢谢帮忙啊!

解决方案 »

  1.   

    select * from table1 join table2 on table1.id = table2.id
      

  2.   


    Select * From table1 a join table2 b on a.id = b.id
      

  3.   

    就是两表联接,select * from table1,table2 where table1.ID=table2.ID
      

  4.   

    用datatable将两者关联的数据读出来,然后用datatable做datagridview的数据源
      

  5.   

    string str_comm=”select * from table1,table2 where table1.ID=table2.ID“;
    string str_conn=“根据自己的服务器添就行了”;
    sqlconnect sql_conn=new sqlconnect(str_conn);
    sqlcommand sql_comm=new sqlcommand(str_comm,sql_conn);
    sqladapter ada=new sqladapter(sql_comm);
    dataset ds=new dataset();
    ada.fill(ds);
    dataGridView.DataSource=ds;
      

  6.   

    Select * From table1 a inner join table2 b on a.id = b.id
      

  7.   

    链表select出来的数据,然后赋值一个datatable,再绑定就可以了