Web SQL Server Learning
Database First Impressions: Desktop--web server--database server**
Several large databases: SQL Server, Oracle database, DB2, MYSQL, MongoDB ..... (SQL Structured Query Language)
Install software: SQL Server Management Studio
Attach, detach (Attach, Detach) database files:
Database Diagram diagram:
Relational database:
Two-dimensional table, primary key, foreign key
Introduction to T-SQL:
T-SQL query--queries requests for information from the database;
The most basic SQL query statement--
*select, *from, WHERE, GROUP by, having, ORDER by
Use statement:
Select...from ... Statement :
Select Top - * from [Production].[Product] --The Top 100 represents the first 100 rows of data, the * symbol selects all, [Production]. [Product] represents a single tableSelectProductID, Name, ProductNumber, Color, Size, ListPrice fromProduction.Product--elect productid,name,productnumber,color,size,listprice these columnsOrder byListPricedesc --DESC stands in reverse order,Order by 2 --2 on behalf of nameIsNull(Name,' ')--IsNull built-in method null value changed to ' '
As keyword Alias
+-*/arithmetic
WHERE statement:
Select... from...whereSaleperson=275 --use where to implement conditional filtering with and, or, Between...and ...whereName Linke'%moutain%' --using like and% to achieve fuzzy lookupswhereColorinch('Red',' White','Black')whereSize is NULL
Aggregation functions:
Select Count(SalesPersonID) fromSales.SalesOrderHeaderwhereSalesPersonID isNoNULL --count number of timesSelect distinct(SalesPersonID) fromSales.SalesOrderHeaderwhereSalesPersonID isNoNULL --Distinct difference valueSelect AVG(List knowledge) asnaming fromForm--avg represents the average, min represents the minimum, max represents the maximum value, sum represents the sum
Group BY Usage:
Select sum as sum of the quantities from A Group by Category -- aggregated into groups according to categories, then the number of individual categories is added
Having
The purpose of the WHERE clause is to remove rows that do not conform to the where condition before grouping the results of the query, that is, filtering the data before grouping, where the cluster function cannot be included, and the Where condition is used to filter out specific rows.
The HAVING clause is used to filter groups that satisfy a condition, that is, to filter the data after grouping, often with clustering functions, to filter out specific groups using the having condition, or to group by using multiple grouping criteria.
Select sum as from A Group by category having sum > - -- Having the function is to filter after grouping
SQL Server Learning