Get the App
SLTechnology News&Howtos  ›  Database  › 

The basic method of operating mysql data Table

Shulou Source: shulou.com Published: 2022-06-01 19:09:38 11月13日 Update

This article mainly introduces the basic methods of operating mysql data table, the contents of the article are carefully selected and edited by the author, with a certain pertinence, the reference significance for everyone is still relatively great, the following with the author to understand the basic methods of operating mysql data table.

1. Create a datasheet

Create table table_name (id int not null auto_increment, name char not null, age int not null, register_date date, primary key (id);)

two。 Insert data (add)

Insert into table_name (name,age,register_date) values ("mxm", 23, "2018-07-13")

3. Query data table (look up)

3.1. Query all data

Select * from table_name

3.2. Query condition

Select column_name,column_name from table_ name [where condition] [limit n] [offset m]

3.3.offset must be used with limit to start with line m

Select * from table_name limit 2 offset 2

3.4.where condition

Older than 23:

Select * from table_name where age > 23

Older than 23 and id greater than 2:

Select * from table_name where age > 23 and id > 2

3.5. Fuzzy query like

Registration date is 2018-07:

Select * from table_name where register_data like "2018-07%"

4. Modify data (change)

Modify the name column m_x_m of the first data

Update table_name set name= "m_x_m" where id=1

5. Delete data (delete)

Delete data with id equal to 1

Delete from table_name where id=1

6. Sort asc/desc

Sort by id

Select from table_name order by id asc

7. Grouping group by

Register each person by the same date corresponding to the registration date and the statistical data query name

Select name,cout (*) from table_name group by register_date

-alter field operation--

8. Add a field

Alter table table_name add sex enum ('0mm, 0mm, 0pm, 1')

9. Delete a field

Alter table table_name drop sex

10. Modify field

Alter table table_name modify sex enum ('01m') not null

After reading the above about the basic methods of operating mysql data sheets, many readers must have some understanding. If you need to get more industry knowledge and information, you can continue to follow our industry information column.

Tags: Data datasheet query field method date condition age author industry sort same number information content name meaning data query article more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Technology MySQL Apple Huawei