1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
| SELECT * FROM students;
SELECT 1;
SELECT * FROM students WHERE (score < 80 OR score > 90) AND gender = 'M';
SELECT * FROM student WHERE score <> 90;
SELECT * FROM student WHERE name LIKE %aokker ;
SELECT score, name FROM students WHERE score >= 85;
SELECT id, name, gender, score FROM students ORDER BY score;
SELECT id, name, gender, score FROM students ORDER BY score DESC;
SELECT id, name, gender, score FROM students WHERE class_id = 1 ORDER BY score DESC;
SELECT id, name, gender, score FROM students ORDER BY score DESC LIMIT 3 OFFSET 0;
SELECT COUNT(*) num FROM students;
SELECT AVG(score) average FROM students WHERE score >= 60 SELECT MAX(name) FROM students SELECT MIN(name) FROM students SELECT SUM(score) sum FROM students
SELECT class_id,gender,AVG(score) FROM students GROUP BY class_id,gender
SELECT * FROM students, classes;
SELECT students.id sid, students.name, students.gender, students.score, classes.id cid, classes.name cname FROM students, classes;
SELECT s.id id c.name cname FROM students s,classes c;
SELECT ... FROM <表1> INNER JOIN <表2> ON <条件...>;
SELECT s.id, s.name, s.class_id, c.name class_name, s.gender, s.score FROM students s RIGHT OUTER JOIN classes c ON s.class_id = c.id;
SELECT s.id, s.name, s.class_id, c.name class_name, s.gender, s.score FROM students s LEFT OUTER JOIN classes c ON s.class_id = c.id;
SELECT s.id, s.name, s.class_id, c.name class_name, s.gender, s.score FROM students s FULL OUTER JOIN classes c ON s.class_id = c.id;
|