MySQL Basic beginner learning "6"

Source: Internet
Author: User

To manipulate records in a data table:

"1" Insert record:  

method One: INSERT [into] tbl_name [(Col_name,...)] {VALUES | VALUE} ({expr |   DEFAULT},...), (...),... You can insert multiple records at once.

If you are ready to assign a value to the default AutoNumber field, it can be written as null or default, which still adheres to the original increment form.

If you omit a column name, all columns must be assigned values in turn.

In addition to writing the exact data, we can also write expressions (mathematical expressions, character expressions, functions).

If some of the fields are given a default value, you can also use default to give it.

We can also write multiple records at once:

MD5 (): A function in PHP that computes the hash of the MD5 of a string

method Two : INSERT [into] tbl_name SET col_name={expr | DEFAULT},...

!!! The difference from the first approach is that this method can use subqueries (subquery)!!!

This method can only insert one record at a time

method Three : INSERT [into] tbl_name [(Col_name,...)] SELECT ...

!!! This method inserts the query results into the specified data table!!!

"2" Update record (single table update):

UPDATE [low_priority] [IGNORE] table_reference SET

col_name1={expr | DEFAULT} [, col_name2={expr| Defaul}] ...

[WHERE Where_condition]

Omitting the Where condition causes all records to be updated

You can update a column, or you can update multiple columns at the same time

You can add conditions during the update process:

"3" Delete record (single table delete):

DELETE from Tbl_name [WHERE where_condition]

Even if the ID number is not contiguous after deleting the record, the maximum value of the ID number is still +1 when the record is inserted again

MySQL Basic beginner learning "6"

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.