In this article I will introduce some examples of common SQL statement directories in everyday programming:
# 1. An example of a database is given in the form of an ER diagram:
4 relational patterns from this conversion: Note: The underscore is a straight line key, and the underscore is a red dashed line for the foreign key
This allows you to create the following database:
C:
S:
SC:
T:
For a specific database setup script, check out my github
# # 2. Common queries
- Query for the minimum age of four persons (sorted by age from small to large, if same age, in name order)
SELECT * from S ORDER by age Asc,convert (SName USING GBK) LIMIT 4
- Check the first two courses of exam time (Examdate is datetime type data)
SELECT * from CORDER by Examdate Asc,convert (cName USING GBK) LIMIT 2
- Get three student data at a random
SELECT * from SORDER by RAND () LIMIT 3
MySQL Common query statement summary (not updated regularly ....) )