1 1 Create Database+Database name creation database2 2 Create Table+Table name creation table3 actions in the table:4 3 Insert intoTable name (column name 1, column name 2 )Values(column value 1, column value 2, column value 3 )5 4 UpdateTable nameSetColumn Name=‘’whereColumn Name="'6 5 UpdateTable nameSetColumn Name=Column Name+' Information to be added 'where=‘’--add information on an existing basis7 6 Delete fromTable namewhereColumn Name="'8 7 Drop TableTable name Delete table name9 Ten Select * fromCar--query car for all columns One Select distinctOil fromCar--eliminate duplicate rows; A SelectName fromCar--Show only a single column - Select distinctBrand fromCar--Show only one column and eliminate duplicate values in this column - Select * fromCarwhereBrand='b003' --equivalent filter "selects columns that are equal to filter items" the Select * fromCarwherePrice> ---do not filter data by value, list data larger than - Select * fromCarwherePrice< ---no equivalent sieve; data that lists data that is less than a certain value - Select * fromCarwherePrice>30 andPrice< ---Multi-Criteria filtering - Select * fromCarwherePrice> - andOil<--logical ' and ' with words and + Select * fromCarwherePrice> - orPrice< ---logical ' or ' with a word or - Select * fromCarwherePricebetween - and ---Select a car with a price between 30.5 million + Select * fromCarwhereName like'Audi%'--% has any number behind. Fuzzy query like A Select * fromCarwhereName like'% Type'--End type query, fuzzy query at Select * fromCarwhereName like'%5%'--mid-query, fuzzy query - Select * fromCarwhereName like '__5%'--Number of numbers in the middle of a fuzzy query - Select Top Ten * fromCar Price--filter out the top 10 cars by Price - Select distinctExhaust fromCarwherePrice> + andPrice< - --displacement type between 40 and 500,000 - Select * fromFruit--Show fruit This column - UpdateFruitSetNumbers=Numbers- - whereName='Orange'--change the value of a column directly in UpdateFruitSetNumbers= - whereName='Apple'--change the value of an item directly - UpdateFruitSetPrice=5.2, source='Feicheng', numbers= - whereName='Peach'--Note When changing multiple items, add commas; to SelectName, price*Numbers'cost' fromFruit--Add column names + --select name ' cost ' from Price - Select * fromCarOrder byPriceASC--by Price Ascending the Select * fromCarOrder byPricedesc--by Price Descending * Select * fromCarOrder byOilASC, Pricedesc --according to the fuel consumption of small to large sort at the same time according to the price from big to small, $ Panax Notoginseng 5.24 - Select * fromproductorders the --SELECT AVG (unit Price * quantity) as average amount from productorders WHERE location = ' North America ' + --find out the average amount of all orders in continental North America. Note that we need to multiply the quantity column and the Unit Price column to calculate the total amount of each order. A --SELECT COUNT (*) as ' large order quantity ' from Productorders WHERE quantity > 100--Product Sales Manager wants to know how many orders the company has processed to purchase more than 100 products the SELECT COUNT( AllLocation as 'Number of locations' fromProductorders--Number of locations (all, repeat) + SELECT COUNT(distinctLocation as 'Number of locations' fromProductorders--Number of locations (No duplicates) - Select MAX(Quantity*Price as 'Maximum Order' fromproductorders $ Select MAX(Quantity*Price as 'Maximum Order' fromproductorders $ SELECT SUMNumber as 'Total' fromproductorders - SELECTLocationMIN(Quantity*Price as 'Minimum Order' fromProductordersGROUP byLocation--Grouping - the - SelectSno,cno,degree,rank fromScore1JoinGrade onScore1.degree>Grade.low andScore1.degree<Grade.uppWuyi Select * fromGrade the Select * fromScore1 - --the Sno, CNO and rank columns of all students are now queried.
SQL---Instruction instance statement