Select * from as T1 Select * from dbo. Table_1 T1
As distinguished name \ All columns, partial columns
Query the first n part of the data:
Top N Column Name: Indicates the first n rows to view
Top N Percent Column name: Indicates the data for the first few percent of view
select * From dbo. Table_2-- Look at table 2nd, all data select top 3 * from dbo. Table_2-- No. 2nd table top three data select top 3 percent * from dbo. Table_2-- 2nd data before table 3
Sort: Order By column name 1 asc|desc, column name 1 ASC|DESC ... desc descending asc Ascending row
Select * from dbo. table_2orderbydescdesc-- check all data in table 2nd, sorted by Sid Descending, secondary to CID descending
Eliminate duplicate rows: Distinct
Select distinct from dbo. Table_2-- Check table 2nd and delete duplicate rows in classid column
Where condition
Write in the Where: Filter the row, return a value of type bool, or join the result set if the column data in a row satisfies the condition
Comparison operators: =,>,>=,<,<=,!= or <>
Select from where sid>2-- student number greater than 2 for all student names
Between ... Expressed in a contiguous range
Select from where between 2 and 3 -- Student number 2 to 3 for all student names
In means within a discontinuous range
Select * from where inch (3,1,6) -- Student number 1,3,6 all students
Logical operators: And,or,not
Select * from where sid=3or sid=4-- student number 1,4 all students
SELECT * FROM dbo. table_2 where Sid not in (3,4,5)--student number not 3,4,5 all students
Fuzzy query: A value used to handle string types, including: like% _ []
Select * fromTable_2whereSname like '%e%'--Check the information in the name of table 2nd with ESelect * fromTable_2whereSname like 'q%'--Query the information in the name of table 2nd with the beginning of QSelect * fromTable_2whereSphone like '1[5-9]%'--for information on mobile phone number 15~19 in table 2ndSelect * fromTable_2whereSphone like '1[^5-9]%'--Check the phone number in table 2nd is not 15~19 information
% with _ written in [] means that the meaning of itself in [] indicates that a contiguous range can be written in [] at the beginning of the []-^, indicating that no internal characters are used
The LIKE keyword% represents 0 to more arbitrary characters _ an arbitrary character "^ non"
NULL judgment: null is used when computed with other values, NULL is considered to be the smallest when evaluated with IS NULL or is not NULL
Select * from where is NULL -- Query number 2nd number in the table is null information Select * from where is not NULL -- Query the phone number in table 2nd is not null information
Query for SQL tables