zoukankan      html  css  js  c++  java
  • [IT学习]sql 入门及实例

    sql 是一种数据库查询语言,可以让你很快的查询到数据。其实一般情况下,你也可以采用excel来查询数据库数据。

    但是人们通常认为sql会更加灵活和方便一些。

    sql学习的入门网站:

    http://www.w3schools.com/SQl/sql_orderby.asp

    https://en.wikipedia.org/wiki/SQL

    sql 学习笔记:

    1、如果你对结构化数据库有概念,那么还是很容易理解的。如果你对结构化数据库一点没有概念,请自行百度结构化数据库,对数据库结构、表、字段、查询(筛选)、增删改、排序数据表等操作有个基本了解。

    2、从Customers 表中查询Country字段内容以U开头的记录。

    SELECT * FROM Customers
    WHERE Country like "U%";

    3、从Customers 表中查询Country字段为USA,并且City字段内容为Seattle或者以P开头的记录。

    SELECT * FROM Customers
    where Country ="USA" and (City ="Seattle" or city like "P%");

    4、从Customers 表中查询City字段内容不重复的记录内容,仅仅返回City字段。(Distinct用来返回字段唯一不重复值的命令)

    SELECT DISTINCT City FROM Customers; 

    5、Like 语句,S%,%S,%Sand%,分别表示S开头,S结尾,包含Sand

    SELECT * FROM Customers
    WHERE Country LIKE '%land%';

    6、fuction 实例:

    SELECT Employees.LastName, COUNT(Orders.OrderID) AS NumberOfOrders FROM (Orders
    INNER JOIN Employees
    ON Orders.EmployeeID=Employees.EmployeeID)
    GROUP BY LastName
    HAVING COUNT(Orders.OrderID) > 10;

    SELECT ProductName, Price FROM Products
    WHERE Price>(SELECT AVG(Price) FROM Products);

    7、Join的四种

    SQL INNER JOIN

    SQL LEFT JOIN

    SQL RIGHT JOIN

    SQL FULL OUTER JOIN

    8、Union与Join的区别

    The UNION operator is used to combine the result-set of two or more SELECT statements.

    Notice that each SELECT statement within the UNION must have the same number of columns. The columns must also have similar data types. Also, the columns in each SELECT statement must be in the same order.

    SQL JOIN

    An SQL JOIN clause is used to combine rows from two or more tables, based on a common field between them.

    The most common type of join is: SQL INNER JOIN (simple join). An SQL INNER JOIN return all rows from multiple tables where the join condition is met.

  • 相关阅读:
    JS实现右侧悬浮框随着页面的上下轮动而移动
    js实现一个简单的时钟表
    js实现前后端分离点击新闻列表跳转到相应的详情页
    获取当前时间的年、月、日
    点击获取今天时间、明天时间、本周时间、本月时间
    判断是不是ie7浏览器,把https换成http(兼容ie7)
    jq控制class相同点击隐藏当前相同的父元素
    js、jq控制class相同当子元素为空时,父元素隐藏
    photoshop
    不得不说一下vite
  • 原文地址:https://www.cnblogs.com/viphhs/p/4976454.html
Copyright © 2011-2022 走看看