1T-SQL Simple query statement2 3 Simple query:4 51.The simplest query (check all data)6SELECT * from table name; NOTE: *represents all Columns7SELECT *From info8 92.querying a specified columnTenSelect Code,name from Info One A3.Modify the column name of the result set -Select Code as' Code ', name asNameFrom info - the4.Conditional Query -SELECT * FROM info where code= ' p003 ' - -5.Multi-Criteria Query + query all data in the Info table for code p003 or nation to n001 -SELECT * FROM info where code= ' p003 ' or nation= ' n001 ' + querying data in the Info table for code p004 and nation to n001 ASELECT * FROM info where code= ' p004 ' and nation= ' n001 ' at -6.Scope Query -SELECT * from car where price>=40 and price<=60 -SELECT * from car where price between and 60 - -7.Discrete Query inCheck car prices in (10,20,30,40,50,60) The car information that appears in -SELECT * from car where price=10 or price=20 or price=30 or price=40 or price=50 or price=60 to +SELECT * from car where price in (10,20,30,40,50,60) -SELECT * from car where price not in (10,20,30,40,50,60) the *8.fuzzy query (keyword query) $ query car table inside name contains Audi'sPanax NotoginsengSELECT * from car where name '% audi% 'any of n characters - Query car Name The second character is ' horse ' in cars theSELECT * from car where name like ' _ Horse% ' _ any one character
9.* * * from Car ORDER BY brand,price Desc
110.go to re-query2 SELECT distinct brand from car3 411.Paging Query5 page 10 of the current is the 3rd page6SELECT * FROM Chinastates limit 20,107 8 one page shows M bar is currently page N9Limit (n-1) *m,mTen One12.aggregate functions (statistical functions) ASelectCount(AreaCode) from Chinastates#query data Total number of bars -Select SUM (price) from car#sum -Select AVG (price) from car#Find Average theSelectMax(price) from car#To find the maximum value -Selectmin(price) from car#To find the minimum value
Group Query Query How many cars are under each series in a car table Select Brand,Count(*) from car GROUP by brand
1 Inquiries the number of cars sold in the car table is more than 1 series 2 Select brand from Car GROUP by Brand have Count(*) >1< /c0>
T-SQL Simple query statement (fuzzy query)