SQL Basic Query Collection

Source: Internet
Author: User
Tags bulk insert

Grant all on * * to ' root ' @ ' localhost ' identified by PASSWORD ' *6bb4837eb74329105ee4568dda7dc67ed2ca2ad9 ' with GRANT OPT ION; unblock revoke all on * * from ' root ' @ '% '; flush privileges; Delete database drop library name; Modify database Alter Library Name property Set property value For example: Alter DATABSE user character set UTF8; View Form properties desc table name; Rename table rename table name to new name; Delete column ALTER TABLE name drop column name; Delete Row Delete FRO M table name where field name = ' field value '; Change data Update table name set field name = ' Where conditional formatting delete truncatetruncate table table name; CREATE TABLE table name (Field Name Fields property,.  ... .... , ... .... Note that there can be no comma here); View the form in the database show tables; The table is followed by S; Insert insert into table name (column name, column name ...) Values (value, value, ...); Bulk INSERT into table name (column name, column name ...) Values (value, value, ...), (value, value, ...), (value, value, ...), etc.; Query data (conditional query) 1. AND2.   Or3.between And:select * FROM table name where field name between ' Value a ' and ' value b '; A&LT;B4.IN:SELSCT * from table name where field name in (value A, value B, ...); In front can be added not5.!  = = > < <> (not equal to) <= >= fuzzy query 1. Contains the character a:like '%a% '; 2. The 3rd one is the character a:like ' __a% '; field control query 1. Go to heavy distinct:select distinct * from table name; 2. Summation: Select null-free column +ifnull (column allowed, 0) [as] sum from table name; sum: equals to rename query result as can omit 3. Sort: Ascending order by column A [ASC], column B [ASC],; Descending order BY column A desc, column B [DESC]; When column A is equal, it is arranged in column B; 4. aggregate function <1> Total number of records in query table select COUNT (*) as total number of entries from table name; <2> the query table has a quantity of one or more fields that are non-null values?????????????????? ?? Select count (field name), Count (field name) ... as number from table name; <3> query table A field value satisfies the number of criteria select COUNT (*) as number of bars from table name where field name > condition; sele CT Count (*) as bar number from table name where field name +ifnull (field name, 0) > condition; <4&gt: Sum of total select sum (field name 1+ifnull (field name 2,0)) As Field 1 and field 2 for all data and from table names; Select sum (field name 1) +sum (field Name 2) As Field 1 and field 2 for all data  The From table name; <5&gt. Average Select AVG (field name) as field average from table name; query highest value Select MAX (field name) the highest value of the As field, min (field name) the lowest value of the As field name from The name of the table; <7&gt. Group Query Select Outer table Link field, function (the field of this table) from the name of the Where Condition Group by outer sheet link field; <8> filter HAVING clause "can be used after group by and where You cannot use a select out-of-table link field after group BY, a function (this table field) from the name of the Where Condition group by outer Link table field has a (must be the fields after this sesect) > condition;

SQL Basic Query Collection

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.