MySQL select query, function functions

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.