zoukankan      html  css  js  c++  java
  • SQL语言基础

    主要学习链接1

    http://www.cnblogs.com/anding/p/5281558.html

    搜索学习链接2

    http://www.cnblogs.com/libingql/p/4134298.html

    在链接1中 里面使用的语法为MYSQL语法,而我学习使用的是MS SQL,所以便有了学习链接2做参考学习

    在学习过程中产生不了解的问题:
    1  SQL建表语句语法区别

      自动递增列 SQL Server 是 : IDENTITY ----MySQL是: AUTO_INCREMENT

      SQL Server 有计算列 ---- MySQL 没

      SQL Server 有 check 约束 ---- MySQL 没

      MySQL 有 enum

    2 SQL数据类型区别

     SQL Server 没有double只有float,如固定小数位可用numric,整数小数都出现使用real

    3 嵌套查询

      MS SQL 错误:无法绑定由多个部分组成的标识符 "xxxxx"

      在自连接多表时,参考链接2

    SELECT c1.CategoryID, c1.CategoryName
    FROM [dbo].[Category] c1 INNER JOIN [dbo].[Category] c2
    ON c1.[CategoryID] = c2.[ParentID]
    

      在上述基础上,将 表 改进为 条件查询表

    select st.[Name],c1.Score,c2.Score from
    (select sc.[Score], sc.[StudentID] from Score sc where sc.[CourseID]=1 )c1
    join (select sc.[Score], sc.[StudentID] from Score sc where sc.[CourseID]=2 )c2 
      on c1.[Score]>c2.[Score] and c1.[StudentID]=c2.[StudentID]
    join Student st on st.[ID]= c1.[StudentID]
    

    4 Group By

      GROUP BY 语句用于结合合计函数

      

  • 相关阅读:
    1014. 福尔摩斯的约会
    1009. 说反话
    1002. 写出这个数
    1031. 查验身份证
    1021. 个位数统计
    1006. 换个格式输出整数
    1058. A+B in Hogwarts
    1027. Colors in Mars
    1019. General Palindromic Number
    Windows 新装进阶操作指南
  • 原文地址:https://www.cnblogs.com/MrGrz/p/5746500.html
Copyright © 2011-2022 走看看