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

Simply understand the basics of MySQL database

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly gives you a brief introduction to the basic knowledge of MySQL database. You can look up the relevant professional terms on the Internet or find some related books to supplement them. We will not dabble here, so let's go straight to the topic. I hope this article on the basics of MySQL database can bring you some practical help.

SQL statement practice-- DML statement (key point)

Select: select * from table1 where range

Insert: insert into table1 (filed1,filed2) values (filed1,filed2)

Explanation: filed1,filed2 field name; filed1,filed2 field value

Deleting: delete from table1 where ran

Updating: update table1 set field1=value1 where ran

Find: select * from table1where filed1 like'% value1%'

Explanation: find a fuzzy match containing value1

If the search starts with value1, use 'value1%'

If the search ends with value1: use'% value1'

Sort: select * from table1 order by filed1,filed2 [desc]

Explanation: [desc] flashback [asc] positive order

Total: select count (*) as totalcount from table1

Summation: select sum (field1) as sumvalue from table1

Average: select avg (field1) as avgvalue from table1

Maximum: select max (field1) as maxvalue from table1

Minimum: select min (field1) as minvalue from table1

Hands-on exercises:

1) insert

Insert four pieces of data into persion_info:

Statement: (person_id is self-growing, so you don't have to write)

Insert into person_info (name,country,salary)

Values ('Xiao Zhao', 'China',1200.01)

('small money', 'Shanghai', 1600.32)

('Xiao Sun', 'Guangzhou', 2000.40)

('Xiao Li', 'Zhuhai', 1670.88)

Execution result:

2) Update:

If you want to change Xiao Zhao's country field to Beijing, execute the statement:

Update person_info set country = 'Beijing' where name = 'Xiao Zhao'

The results are as follows:

3) sort

Sort the name by order by

Statement: select * from person_info order by name desc

Running result:

4) find

Find the fuzzy matching data containing "Zhao", sentence ""

Select * from person_info where name like'% Zhao%'

Running result:

5) Total

Find the total number of data items in the person_info table

Statement: Select count (*) as totalcount from person_info

Execution result:

The visible result is 4, and the field name is totalcount.

6) summation

Statement: select sum (salary) as sumvalue from person_info

Execution result:

The basics of MySQL database will first tell you here, for other related issues you want to know can continue to pay attention to our industry information. Our section will capture some industry news and professional knowledge to share with you every day.

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