zoukankan      html  css  js  c++  java
  • SQL server表连接

                            表连接

    1、select * from student,score ——笛卡尔积

    2、两个表的连接:

    法1:select student.sno, sname, degree from student,score where student.sno=score.sno ----当查询的列名两个表中都有时要在列名前面加上‘表名.’

    法2:select student.sno ,sname,cno,degree from student join score   on student.sno=score.sno   

    --- //inner join(默认) //left join(以左表为主表)  //right join(以右表为主表)

         

    3、多个表的连接

    法1:

          select student.sno, sname, cno, degree, name   

    ---注:select student.sno, sname, cno, degree+10, name+‘同学’ 结果是:成绩增加10分,名字后面加上同学

          from student,score,course  where student.sno=score.sno and   score.cno=course.cno

    ----当查询的列名不只存在1个表中都有时要在列名前面加上‘表名.’

          

    法2:select student.sno, sname, cno, degree, name from student join score on student.sno=course.sn  join course on score.cno=course.cno

    4、纵链接

    unine

  • 相关阅读:
    20170612测试
    vijos1453曼哈顿距离
    vijos1153 猫狗大战
    vijos1037搭建双塔
    dijkstra+priority_queue+vector
    BZOJ1507: [NOI2003]Editor
    dinic模板
    旅行-树形DP
    51nod1799-二分答案
    51nod1791-合法括号子段
  • 原文地址:https://www.cnblogs.com/zhulijun/p/6558421.html
Copyright © 2011-2022 走看看