还有
2,你如果要在dataset中加入多个表,你可
sqlDataAdapter sa=new sqlDataAdapter()
sqlCommand sc=new sqlcommand();
sa.selectcommand=sc;
sc.connection=conn;
DataSet ds=new DataSet();
sc.commandtext="select * from student"
sa.fill(Ds,"student");
sc.sc.commandtext="select * from score"
sa.fill(Ds,"score");
sc.sc.commandtext="select * from course"
sa.fill(Ds,"course");然后用
ds.tables["course"]
ds.tables["student"]
ds.tables["score"]
这样的话得到的是三个表的所有纪录,我现在想要做的是只提取一部分纪录,比如提取学号为s302010001的学生的所有信息,其中学号在student表里面,student和score中xsid分别为主键和外键score和course中kcid分别为主键和外键!!

解决方案 »

  1.   

    不用内连接
    用条件查询可以的
    select * from xsda ,pyjh where xsda.xsid=pyjh.xsid and xuehao='s302010001'
      

  2.   

    xsda代表我的学生档案表,pyjh代表我的培养计划表,两个表里面都有xsid(学生id)数据项
    学生档案里面还有的数据项是姓名(xingming),学号(xuehao)等,培养计划里面还有的数据项为选课名称(kcmc),课程id(kcid)等
      

  3.   


    select * from xsda ,pyjh where xsda.xsid=pyjh.xsid and xuehao='s302010001'
    就可以
    关系有不是很复杂,干吗考虑那么多那
      

  4.   

    select * from xsda inner join pyjh on xsda.xsid=pyjh.xsid where xsda.xuehao='s302010001' and pyjh.xuehao='s302010001'",
      

  5.   

    select * from xsda inner join pyjh on xsda.xsid=pyjh.xsid where xsda.xuehao='s302010001' or pyjh.xuehao='s302010001'"
      

  6.   

    select * from xsda inner join pyjh on xsda.xsid=pyjh.xsid where xsda.xuehao='s302010001' or pyjh.xuehao='s302010001'
    OR
    select * from xsda,pyjh where xsda.xsid=pyjh.xsid and (xsda.xuehao='s302010001' or pyjh.xuehao='s302010001')
    ……
      

  7.   

    可将三个表一起取,得到一个结果集,形式如
    select student.*,score.*,course.* from student inner join score on score.xsid=student.xsid inner join inner on score.kcid=course.kcid 
    where student.xuehao='s302010001'