Mysql SQL statements Daquan

Source: Internet
Author: User

Mysql SQL statements Daquan

1, Description: Create DATABASE dbname;

2. Description: Delete database drop DB dbname;

3. Description: Creating a new Table CREATE table tabname (col1 type1 [NOT NULL] [primary key],col2 type2 [NOT NULL],..);

4. Description: Delete new table drop table tabname;

5. Description: Add a column Alter table tabname add column col type;

6, Description: A few simple basic SQL statements
selection: SELECT * from table1 where range;
insert: INSERT INTO table1 (field1,field2) values (value1,value2);
Delete: Delete from table1 where range;
Updated: Update table1 set field1=value1 where range;
Find: SELECT * FROM table1 where field1 like '%value1% '---the syntax of like is very subtle, check information!;
Sort: SELECT * FROM table1 ORDER by field1,field2 [DESC];
Total: Select count as TotalCount from table1;  
sum: Select sum (field1) as Sumvalue from table1;
Average: Select AVG (field1) as Avgvalue from table1;
Maximum: Select Max (field1) as MaxValue from table1;
min: select min (field1) as MinValue from table1;

7, left JOIN Connect:

  Left join: Returns all fields in the left table that match the criteria in the table to the right.  

JOIN  on Stu.classe_name=tech.classe_name;

Here are two tables:

Table Stu

  

Table Tech

  

The results are as follows:

8. Internal connection:

  Returns an entry in the table that meets the criteria.

JOIN  on Stu.classe_name=tech.classe_name;

The results are as follows:

9、右连接: returns all fields in the right table that match the criteria in the table on the left.
JOIN  on Stu.classe_name=tech.classe_name;

The results are as follows:

 

Mysql SQL statements Daquan

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.