In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following content mainly brings you the query methods of commonly used sentences in mysql. The knowledge mentioned here, which is slightly different from books, is summed up by professional and technical personnel in the process of contact with users, and has a certain value of experience sharing. I hope to bring help to the majority of readers.
Basic statement
1. Mysql-u root-p database connection
2. Create a database by create databases database name
3. Delete the database by drop database database name
Query statement
4. SELECT * FROM table name queries all data in the table
5 、 SELECT idcard,name
FROM student conditional query
6 、 SELECT DISTINCT addr
Duplicate values are output only once when queried by FROM student
7. SELECT *
FROM student
WHERE idcard=1; queries student information with idcard 1
8. SELECT *
FROM student
WHERE name= "TOM" AND age=18; query name is TOM and age is 18
9. SELECT *
FROM student
WHERE name= "T" OR age=18; query name is T or age is 18 to meet a condition
10 、 SELECT idcard,name,age
FROM student
ORDER BY age; query in ascending order of age
11. INSERT INTO student VALUES (7, "MARRY", 22 # 1, "Zhejiang Shaoxing"); insert data like a table
12. UPDATE student SET gender = 0; update the data of a column in the table
13. UPDATE student SET gender = 0
WHERE idcard=1; updates the data of a row and column in a table
14 、 DELETE
FROM student
WHERE idcard = 5; delete the row with idcard 5
15. SELECT *
FROM student
WHERE addr LIKE "% Lake%"; all those with lakes in the query address are output.
16. SELECT *
FROM student
WHERE idcard IN (1, 2, 4, 7); query all data with idcard of 1, 2, 4, 7
17 、 SELECT idcard AS id,name,age,gender,addr
FROM student changed the alias of idcard to id to show it.
18, SELECT student.`name`, student.age,student.addr,course.course_name,mid_stu_course.grade
FROM student
JOIN mid_stu_course ON student.idcard=mid_stu_course.idcard
JOIN course ON mid_stu_course.course_id=course.course_id
WHERE student.idcard=1; queries the information of students with idcard 1
19 、 SELECT student.idcard
FROM student
UNION
SELECT mid_stu_course.course_id
FROM mid_stu_course; query results and merge result sets
For the above query methods about the commonly used sentences in mysql, if you have more information, you can continue to pay attention to the innovation of our industry. If you need professional answers, you can contact the pre-sales and after-sales on the official website. I hope this article can bring you some knowledge updates.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.