Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The basic method of operating mysql data Table

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report