Add, delete, modify and check mysql data table

1. Select query

Query all records in the datasheet table

select * from datasheet //数据表

Query records containing id and name fields in the table

select id,name from datasheet

The record with id = 1 in the conditional query table

select * from datasheet where id = 1

Sort query is sorted by age in descending order

select * from datasheet order age desc // asc 升序

Limit query to retrieve the 10 largest data of age

select * from datasheet order age desc limit 10

2, insert insert

Insert a new record into the table

1. Insert into table name (field) value (record corresponding to the field) <suitable for multiple inserts>

insert into datasheet(id,name) value(10,Tom)

2. Insert into table name set field one = value one, field two = value two <suitable for single insert>

insert  into datasheet set id = 10, name = "Tom";

Insert multiple new records into the table

insert into datasheet(is,name) value(10,Tom),(11,Make)

3. Update

Change the name of the id = 1 record in the table to Tom

update datasheet set name = "Tom" where id = 1

4. delete delete

Delete the record with id = 1 in the table

delete * from datasheet where id = 1

Guess you like

Origin blog.csdn.net/weixin_46329969/article/details/109430246