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 cno, (select sname from student where student.sno=score.sno),degree from score

    法3:select student.sno ,sname,cno,degree

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

           on student.sno=score.sno

    3、三个表的连接

    法1:

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

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

           where student.sno=score.sno

           and   score.cno=course.cno

    法2:select student.sno, sname, cno, degree, name

           from student join score

          on student.sno=course.sno

              join course

         on score.cno=course.cno

    4、纵链接

          

  • 相关阅读:
    使用RAID与LVM磁盘阵列技术
    挂载硬件设备和磁盘容量配额
    文件存储结构(FHS标准)物理设备命名规则(udev)和文件系统
    文件访问控制列表
    逻辑漏洞
    web渗透思维导图
    常见漏洞简单测试整理
    Python知识点图片
    python控制流
    Python小知识点+保留字
  • 原文地址:https://www.cnblogs.com/weiyu11/p/6543820.html
Copyright © 2011-2022 走看看