One, select query
//querying all the data in a single tableSelect * from Temp;//querying data for specified columns and criteria//query Both the name and age columns, and age equals 22 of the dataSelectName,age from Temp whereAge= A;//As to rename name//as can be omitted without writing, if the renamed column name appears special characters, such as single quotes, then you need to enclose the double quotation marks on the outsideSelectName as 'name' from Temp;//alias table.SelectT.name Name from Temp asT;//Where Condition query>、>=、<、<=、=、<>can appear in the WHERE statementSelect fromTwhereA> 2 orA>=3 orA<5 orA<=6 orA=7 orA<>0;//andand//the query name equals Jack and is older than 20Select * from Temp whereAge> - andName= 'Jack';//or or--Meet one conditionSelect * from Temp whereName= 'Jack' orName= 'Jackson';//betweenV andv2--greater than or equal to V and less than or equal to V2Select * from Temp whereAgebetween - and -;//inEnquiry--can have multiple conditions, similar to or--The data that the query ID appears in parenthesesSelect * from Temp whereIdinch(1,2,3);//Like fuzzy query--Query name starts with JSelect * from Temp whereName like 'j%';--Query name contains the KSelect * from Temp whereName like '%k%';--Escape escape, specifying \ As the escape character, the above can query the name contains "_" DataSelect * from Temp whereName like '\_%' Escape '\';// is NULL、 is not NULL--data that is queried as nullSelect * from Temp whereName is NULL;--querying for data that is not NULLSelect * from Temp whereName is not NULL;//Order by--Sort, Ascending (desc), descending (ASC)--Default AscendingSelect * from Temp Order byID;Select * from Temp Order byIdASC;--multi-column combinationSelect * from Temp Order byID, age;//notSelect * from Temp where not(age> -);Select * from Temp whereId not inch(1,2);//distinct remove Duplicate dataSelect distinctId from Temp;//multiple columns will be combined with duplicate dataSelect distinctID, age from Temp;//Query ConstantsSelect 5+2;SelectConcat'a','BBB');//concat function, string connection//concat and Null are connected, which causes the concatenated data to become nullSelectConcat (Name,'-eco') from Temp;//operations on the data of the querySelectAge+2, age/ 2, age- 2, age* 2 from Temp whereAge- 2 > A;
MySQL select query, function functions