Summary of Mysql Data operation statements

Source: Internet
Author: User

Data Operations

Select -- retrieve data rows and columns from database tables

Insert -- add new data rows to the database table

Delete -- delete data rows from a database table

Update -- update data in the database table

Select

General format:

Select * (field name 1...) from table_name (table name ...)

Where (where clause)

Order by field name DESC (order by clause)

Group by field name (group by clause)

 

(Field name 1 ...)

You can query multiple fields and use functions such as sum (), max (), min (), and count! The AS alias can be used.

(Table name ...)

Multiple tables can be queried in combination.

(Where clause)

Like, And, Or, between... and.

Like '% find this %'
Like '[A-Za-Z] %' --------- ([] specifies the range of values)
Like '[^ F-M] %' --------- (^ exclude specified range)

Between 20 and 100 -------------- indicates that the condition is in a range.

In (, 30) --------------------------- qualifier

(Order by clause)

Order by stockid DESC (ASC) --------- sort, desc-descending, ASC-ascending
Order by 1, 2 --------- by column number

(Group by clause)

Group by groups tables by row. The specified columns have the same values.
Having count (*) = 2 --------- having: select the specified group.

Keywords

Distinct ----------------- distinct

Select distinct column_name form table_name

Subquery ()

 

(To be sorted out)

 

Query Efficiency

Stored Procedure> static view> dynamic connection> subquery

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.