SELECT * FROM student LIMIT 2,6
SELECT * FROM student LIMIT 10,10
SELECT * from student ORDER BY age DESC
SELECT * FROM student DRDER BY age DESC ,math ASC
SELECT COUNT(id) AS 总人数 FROM student
SELECT COUNT(*) AS 总人数 FROM student
SELECT IFNULL (ID,0) FROM student
SELECT COUNT(IFNULL(english ,0) ) FROM student
SELECT COUNT(*) FROM student WHERE age >20
SELECT SUM(math) from student
SELECT AVG(math) from student
SELECT MAX(math) from student
SELECT MIN(math) from student
SELECT * FROM student GROUP BY sex;
SELECT sex, AVG(math) AS 平均分 FROM student GROUP BY sex;
SELECT sex AS 性别, COUNT(*) AS 人数 FROM student WHERE age > 25 GROUP BY sex
SELECT sex AS 性别, COUNT(*) AS 人数 FROM student WHERE age > 25 GROUP BY sex HAVING COUNT(*)>2
ALTER TABLE employee DROP FOREIGN KEY emp_dpid_fk
ALTER TABLE employee ADD CONSTRAINT emp_dpid_fk FOREIGN KEY (emp_id) REFERENCES department(id)
多对多都是通过第三张表来表示中间关系
SELECT * FROM emp ,dept WHERE emp.dep_id =dept.id;
SELECT * FROM emp INNER JOIN dept ON emp.dep_id =dept.id;
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/justleavel/article/details/123309522
内容来源于网络,如有侵权,请联系作者删除!