A表只有id
B表有姓名,但也要有相应的字段能和A表对应起来,如idselect a.id,b.name from a,b where a.id=b.id;

解决方案 »

  1.   

    select name,subject from t_student stu,t_subject sub
    where stu.id=sub.id
      

  2.   

    table1表:ID,name, ...
    tble2表:ID,kecheng, ...select a.name, b.kecheng from table1 a,table2 b
      where a.ID = b.ID;
      

  3.   

    我要返回的数据可能是多条的,怎么样使这多条的std_id和std_name分别对应啊?
      

  4.   

    table1表:学生ID,姓名,……
    table2表:学生ID,课程,……Select a.姓名, b.课程 from table1 a,table2 b
      where a.学生ID = b.课程 (+)
      

  5.   

    选课表:
    course_id  course_name  std_id
    学生信息表:
    std_id     std_name   .........我现在要想得到选course_id=1的所有学生的姓名(即std_name)和与之对应的course_name,怎么做?谢谢
      

  6.   

    看来你对SQL很陌生,这是一个很基本的SQL语句。
    select a.std_name,b.course_name
    from 学生信息表 a,选课表 b
    where b.course_id=1 and b.std_id=a.std_id;
      

  7.   

    不会的!
    在学生信息表里 std_id 肯定是唯一的,
    在选课表里面,同一个std_id可以有多个course_id
    即:
    std_id  course_id
    123     1
    123     2
    123     3因此 std_id和course_id相加是唯一的
      

  8.   

    我要的到的效果是:
    std_id    course_id    std_name
    1             1          heh 
    2             1          hello
    3             1          kkdd
      

  9.   

    To: ljfppp(点到点)
        你怎么知道我说的不行啊,你试过我的SQL语句了吗???????????
    我只是列举了一个学生的情况,所以只能查到一条记录.你的表里当然
    不会只有一个学生了,因此你用我的SQL语句可以满足你的要求!!!!!!    我说你对数据库没有什么概念, 也不懂SQL.不过只要多实践,会长进很快的.
      

  10.   

    如果你的表结构和表记录是这样的,那么我刚才说的SQL语句若不能达到你的要求,你再来找我!!!!!!!!!!!!!!!!!!!!!!!!!!!select a.std_name,b.course_name
    from 学生信息表 a,选课表 b
    where b.course_id=1 and b.std_id=a.std_id;
    学生信息表                    选课表
    std_id  std_name             std_id  course_id  course_name
    1       猪八戒                1        1         数学
    2       孙悟空                1        2         语文
    3       沙和尚                1        3         英语
                                  2        1         数学
                                  2        2         语文
                                  2        3         英语
                                  3        1         数学
                                  3        2         语文
                                  3        3         英语
      

  11.   

    选课表:
    course_id  course_name  std_id
    学生信息表:
    std_id     std_name   .........select a.std_name,b.course_name
    from 学生信息表 a,选课表 b
    where b.course_id=1 and b.std_id=a.std_id;有错吗?我们以前学vf的时候就是这样写的,我和ATCG(ATCG) 同志的想法一致
      

  12.   

    "SELECT std_info.user_name,std_course.course_id,std_course.course_name FROM std_info,std_courseWHERE std_info.user_id=std_course.user_id AND std_course.course_id=1我写的语句就是这样的,和ATCG的有什么不同,高手指点。比如在course_table中有多个人选了course_id=1的课程,可是如果按照我写的语句就只能选出第一条数据。谢谢