随笔分类 -  搞来搞去还是要优化的SQL

leetcode 620. Not Boring Movies 用where语句判断
摘要:https://leetcode.com/problems/not-boring-movies/description/ 不管题目简不简单,现在先熟悉语法。 直接用where语句判断即可,判断奇偶可以用 % 还有用 & 也行 阅读全文

posted @ 2017-11-26 13:45 stupid_one 阅读(154) 评论(0) 推荐(0) 编辑

leetcode 627. Swap Salary 数据库带判断的更新操作
摘要:https://leetcode.com/problems/swap-salary/description/ 用 set keyWord = Case depentedWord when haha then baba else lala end 最后需要end # Write your MySQL 阅读全文

posted @ 2017-11-26 00:28 stupid_one 阅读(278) 评论(0) 推荐(0) 编辑

leetcode 182. Duplicate Emails having的用法 SQL执行顺序
摘要:https://leetcode.com/problems/duplicate-emails/description/ 首先sql的执行顺序是 from-->where-->group by >having-->select-->order by 所以用了group后,用where判断是错误的 ht 阅读全文

posted @ 2017-11-24 14:29 stupid_one 阅读(129) 评论(0) 推荐(0) 编辑

leetcode 181 Employees Earning More Than Their Managers 不会分析的数据库复杂度
摘要:https://leetcode.com/problems/employees-earning-more-than-their-managers/description/ 老师上课没分析这些的复杂度,我大概认为子查询要O(n^2) 一开始,直接用了子查询,2400ms.... # Write you 阅读全文

posted @ 2017-11-24 13:34 stupid_one 阅读(152) 评论(0) 推荐(0) 编辑

leetcode 176. Second Highest Salary
摘要:https://leetcode.com/problems/second-highest-salary/description/ 题目要求输出第二大的成绩。 首先可以想到去重,然后排序,相当于输出第二个成绩。 这个用limit a offset b表示,从第b项开始,选出a个,下标从0开始 然后,如 阅读全文

posted @ 2017-11-21 20:33 stupid_one 阅读(379) 评论(0) 推荐(0) 编辑

leetcode 175 Combine Two Tables join用法
摘要:https://leetcode.com/problemset/database/ ACM退役,刚好要学sql,一定要刷题才行,leetcode吧。 这一题,说了两个表,一个左一个右吧,左边的personId是唯一的,但是右边的PersonId是不唯一的,所以不去重。 然后,总结下各种join的用法 阅读全文

posted @ 2017-11-21 18:43 stupid_one 阅读(179) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示