Basic operations on MySQL additions and deletions

Source: Internet
Author: User

1. Annotation syntax:--,#
2. The suffix is. sql files are database query files
3. Save the query
4. There's a name in the database that's called the field row.

crud Operations:
Create Creation (ADD)
Read reads
Update Modification
Delete Deletes

1. Add Data
INSERT into Info values (' p009 ', ' Zhang San ', 1, ' n001 ', ' 2016-8-30 12:9:8 ');
Add data to a specific column
Insert into Info (code,name) VALUES (' p010 ', ' John Doe ');
Handling of self-growing columns
INSERT into family values (' ', ' p001 ', ' data ', ' T001 ', ' data ', 1);

Insert into table name values (value)

2. Delete data
Delete all data
Delete from family
Delete a specific data
Delete from Info where code= ' p001 '

Delete from table name where condition

3. Modify the data
Modify all data
Update Info set name= ' Xu Yepeng '
Modify specific data
Update Info set name= ' LV Yongle ' where code= ' P002 '
Modify multiple columns
Update Info set name= ' LV Yongle ', sex=1 where code= ' p003 '

Update table name set the content to be modified where condition TNO =

4. Read data
(1) Simple read, query all columns (*) All rows (no add condition)
SELECT * FROM Info
(2) reading a specific column
Select Code,name from Info
(3) Conditional query
SELECT * from Info where code= ' p003 '
(4) Multi-criteria Query
SELECT * from Info where code= ' p003 ' or nation= ' n002 ' #或的关系
SELECT * from Info where sex=0 and nation= ' n002 ' #与的关系
(5) keyword query (fuzzy query)
Check all cars that contain Audi
SELECT * from car where name like '% Audi% '; #百分号% represents any number of characters
Check all the cars that start with ' crown '
SELECT * from car where name like ' Crown% ';
Query car Name The second character is ' horse '
SELECT * from car where name like ' _ Ma% '; #下划线_代表任意一个字符
(6) Sort query
SELECT * from Car order by powers #默认升序排列
SELECT * from Car order by powers #升序asc Descending desc
Rank by brand in ascending order, and then
SELECT * FROM car ORDER BY brand,price Desc
(7) Scope query
SELECT * FROM car where price9 () >40 and price<60
SELECT * from car where price between and 60

Basic operations on MySQL additions and deletions

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.