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

  • 相关阅读:
    Python电影投票系统
    Python打印一个等边三角形
    打印正直角三角形
    MySQL指令
    MySQL安装 8.0.15版本
    局部变量 全局变量
    目录
    格式化输出
    转义字符
    ffmpeg 从内存中读取数据(或将数据输出到内存)
  • 原文地址:https://www.cnblogs.com/zhulijun/p/6558421.html
Copyright © 2011-2022 走看看