![](https://img-blog.csdnimg.cn/c707fb9bea144f049e937b7f5d238c32.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
数据库
数据库SQL语句练习和数据库原理
「已注销」
这个作者很懒,什么都没留下…
展开
-
数据库:外键约束
现在父类的班级删改的话,可能会出错,因为子表有些学生信息绑定着这个班级,删除无法直接执行。需要在外键约束上再添加一些附加条件。这种方法的使用需要谨慎,因为一但你有什么误操作,连带很多子表列也将被删除。为了建立两表之间的关系 子表需要添加外键约束。首先创建父表 班级表。原创 2023-03-27 20:50:37 · 83 阅读 · 0 评论 -
数据库:上升的温度
题目链接:https://leetcode-cn.com/problems/rising-temperature/# Write your MySQL query statement below#输入:#Weather 表:#+----+------------+-------------+#| id | recordDate | Temperature |#+----+------------+-------------+#| 1 | 2015-01-01 | 10 |原创 2022-05-05 14:44:17 · 450 阅读 · 0 评论 -
数据库:部门工资前三高的所有员工
题目链接:https://leetcode-cn.com/problems/department-top-three-salaries/#Employee 表:#+----+-------+--------+--------------+#| id | name | salary | departmentId |#+----+-------+--------+--------------+#| 1 | Joe | 85000 | 1 |#| 2 | Henry原创 2022-05-03 15:54:59 · 873 阅读 · 0 评论 -
数据库:第N高的薪水
题目链接:https://leetcode-cn.com/problems/nth-highest-salary/#method1#case1CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INTBEGINset N = N - 1; RETURN ( select ifnull( ( select distinct Salary from Employee原创 2022-04-20 18:43:49 · 438 阅读 · 0 评论 -
数据库:第二高的薪水
题目链接:https://leetcode-cn.com/problems/second-highest-salary/#method1#分页查询select ifNull( ( select distinct Salary from Employee order by Salary desc limit 1,1 ),null) as SecondHighestSalaryselect coalesce( ( select distinct S原创 2022-04-11 16:50:17 · 647 阅读 · 0 评论 -
数据库:组合两个表
题目链接:https://leetcode-cn.com/problems/combine-two-tables/#method1select p.FirstName,p.LastName,a.City,a.Statefromperson p left join address aonp.personid=a.personid#method2select FirstName, LastName, (select City from Address a wher原创 2022-04-11 14:28:57 · 425 阅读 · 0 评论