Basic statement
1. Mysql-u Root-p Database connection
2. Create databases database name database
3. Drop DATABASE Database name
Query statements
4.SELECT * from table name query all data in table
5. SELECT Idcard,name
From student conditional query,
6. SELECT DISTINCT Addr
From student query to duplicate value output only once
7. SELECT *
From student
WHERE idcard=1; Query student information for Idcard 1
8. SELECT *
From student
WHERE name= "TOM" and age=18; The query name is Tom and the age is 18
9. SELECT *
From student
WHERE name= "T" OR age=18; The query with the name T or the age of 18 satisfies one condition.
10. SELECT Idcard,name,age
From student
ORDER by age; Search by age in ascending order
11.INSERT into student VALUES (7, "MARRY", 22, 1, "Shaoxing, Zhejiang"); Insert data like a table
12,UPDATE student SET gender = 0; Update data for a column in a table
13.UPDATE student SET gender = 0
WHERE idcard=1; Update data for a column in a row in a table
14.DELETE
From student
WHERE Idcard = 5; Delete a row with a idcard of 5
15. SELECT *
From student
WHERE addr like "% lake"; Query the address with the lake, all output to
16. SELECT *
From student
WHERE Idcard in (1,2,4,7); Query all data for Idcard 1, 2, 4, 7
17. SELECT Idcard as Id,name,age,gender,addr
From student Modify the alias of Idcard to show the ID
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; Find information for students who are idcard to 1
19. SELECT Student.idcard
From student
UNION
SELECT mid_stu_course.course_id
From Mid_stu_course; Query results and merge result sets
This article is from the "Java" blog, so be sure to keep this source http://4534508.blog.51cto.com/4524508/1960941
MySQL Common query statements