• sql server 2008子查询的学习小纪(一)


             对于sql server 2008 数据库的学习,笔者秉承一贯的 学习习惯,将 它做了整理,一便于后来学习时 能找准重点, 有不足之处 请大家 斧正,

          1.  对于任何一种数据库的学习, 主要 抓住对---- 这个概念的 “增(insert)”,“删(delete)”,“改(update)”,“查(select)” 这四个 功能, 而其中 尤其以 学习 “查(select)” 时需要的时间最长,  下面直接 进入对 子查询的  基础演示,

             先创建表:

    create table student(

                       id int identity(1,1)primary key, 
                       name varchar(20),
                       age int not null,
    )

    create table score(

                       id int references student(id), 
                      score varchar(20),

                       classname varchar(20)
    )

          -- 1.现在需要把 每个学生的 成绩 和 他链接起来

            简单查询 1. sql1=select name from  student

                         2.sql2=select score from score 

    -- 链接起来

                select s1.name as 学生姓名, s2.score as 学生分数

                        from (sql1)s1,(sql2)s2 where s1.id=s2.id  

      --小结就是: 你要查的表缺什么 “列”,你就到 这个‘列’  所在的表把 列提取出来,

         或者 你还可以这样来做, 

      --   2.需要求出      有90分数的 学生的 id 和name

               select s1.name as 学生姓名, s1.id as 学生id

                         from (sql1)s1  where s1.id=(select id from score  where score =90 ) 

       -- 小结: 把 一个表中的 列的 一个 唯一的值 当成 条件,

        

  • 相关阅读:
    php数组的循环遍历
    Mysql中的字符串函数
    关于给居于网络里面的计算机发送消息的问题
    WINDOWS系统服务详解
    GET DATA
    无法移动或重命名“Documents and Settings”文件夹
    瑞星升级包 下载网站
    ARP本机绑定 批处理
    如何获得各个运行进程的id
    如何通过程序知道有哪些计算机与自己的电脑连接
  • 原文地址:https://www.cnblogs.com/yyjxxd/p/5319608.html
Copyright © 2020-2023  润新知