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

Operation of adding, deleting, changing and searching function of MySQL

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

Share

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

This article mainly tells you briefly about the operation of the function of adding, deleting, changing and searching MySQL. 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 operation of the function of adding, deleting, changing and searching MySQL can bring you some practical help.

1. Record the operation table (add, delete, modify and search, Create,Read,Update,Delete)

1.Insert

INSERT INTO table_name [(column [, column.])] VALUES (value [, value.])

INSERT INTO employee (id,name,gender,birthday,entry_data,job,salay,resume)

VALUES (null,' Laize ammonium', 'male', '2018-12-8' null,' python engineer', 5000 'anything')

Insert into employee values (null,' Wu Zhixiong, male, 2000-1-1), (null,' Laize ammonium, male, 1996-7-7, 1996-12-8); # all columns can be written without writing, multiple entries can be inserted

2.Update

UPDATE tbl_name SET col_name=exprl [, col_name2=expr2.]

(1) change the salary of all employees to 5000

Update employee set salay= 5000

(2) change the salary of laizemium to 3000

Update employee set salay = 3000 where name=' razonium'

(3) change Hou Wenze's salary from 4000 to C++.

Update employee set salay = 4000 update employee set salay job = 'clockwise' where name = 'Hou Wenzhe'

(4) increase Zheng Jiaying's salary by 1000

Update employee set salay = salay+1000 where name = 'Zheng Jiaying'

3.Delet (truncate) # truncate destroy the whole table

Delete from table_name [WHERE where_definition]

(1) Delete the record named Hou Wenze in the table

Delete from employee where name = 'Hou Wenze'

(2) Delete all records in the table

Delete from employee

(3) use truncate to delete records in the table

Truncate employee

4.Select

SELECT [DISTINCT] * | {column1,column2,.} FROM table

(1) query the information of all employees in the table

Select * from employee

(2) query the names and salaries of all employees in the table

Select name,salay from employee

(3) filter duplicate data in the table

Select distinct salay from employee

(4) + 1000 on the salary of all employees

Select name,salay+1000 from employee

(5) Statistics of the total score of each student

Create table grade (

Id INT primary key AUTO_INCREMENT

Name varchar (20)

Chinese INT

Math INT

English INT

);

Insert into grade values (null,' Hou Wenze', 70d80 90), (null,' Zheng Jiaying', 79 record85 92), (null,' Lai Ze ammonium', 90 daijin40)

Select name,chinese+math+english from grade

(6) use aliases to indicate the total score of students.

Select name as name, chinese+math+english as total score from grade

Select name name, chinese+math+english total score from grade

5. Query with where

(1) check the scores of students whose names are xxx.

Select * from grade where name = 'Lazeonium'

(2) inquire about students whose English scores are greater than 90.

Select * from grade where english > 90

(3) inquire all students whose total score is greater than 230

Select * from grade where chinese+math+english > 230

(4) where common operators

~: > < = # is not equal to

Select * from grade where chinese80

~: between And.... # in between

Select * from grade where math between 70 and 85

~: in (set) # set in parentheses

Select * from grade where english in (80, 85, 90)

~: like # like, wildcard%,'_ 'means a character

Select * from grade where name like 'Lai%'

Select * from grade where name like 'Wen'

~: and or not # logical operator

MySQL add, delete, change and search function operation 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