MySQL Insert tone Common manual

Source: Internet
Author: User

Insert tone belongs to DML

Simple usage: INSERT INTO tb_name (field 1, Field 2, ...) VALUES (value 1, value 2, ...) Attentionthe number of fields must be the same as the number of values。 Characters are quoted in quotation marks, numbers are not used, inserting null values using NULL BULK INSERT: INSERT INTO tb_name (field 1, Field 2, ...) VALUES (value 1, value 2, ...) [, (Value N, value m, ...),.............] Note the comma. The inserted value is not necessarily the value we give, or the expression can be used. For example, if you write 1+2 MySQL will calculate the results, the Insert field can also use the INSERT into Tb_name set set tone similar to the update tone. For example, insert into text set a1=10,a2=11; In the field, A1,a2 inserts the last field in the Data query table select * FROM Tb_name the order by field name DESC LIMIT 1 This indicates that the results of the query will be dropped The sequence display. Then use limit 1 to display the first lineInsert the results of a query in one table into another table, provided that the fields correspond. For example, we query the age field in the student table students, more than 20 of the student name, gender, age, insert Tutors table field, name, age, gender insert into tutors (tname,gender,age) Select Name, Gender,age from students where age>20; inserts data, if the original table is not inserted, there is a replacement. Use replace into and insert the same usage.

MySQL Insert tone Common manual

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.