SQL
文章平均质量分 92
每天的每一天
这个作者很懒,什么都没留下…
展开
-
MySQL性能调优-2-实际优化案例
关于SQL优化的思路,一般都是使用执行计划看看是否用到了索引,主要可能有两大类情况:对业务字段建立了二级联合索引,但是MySQL错误地觉得走主键聚族索引全表扫描效率更高,而没有走二级索引走二级索引,但是引起了几万、几十万的回表,此时还不如利用聚簇索引进行正序或者倒序的全表扫描,配合limit n,全表扫描只需要扫到符合条件的n条就停止。原创 2023-12-04 09:59:49 · 710 阅读 · 0 评论 -
【sql学习】LeetCode之182. Duplicate Emails
Write a SQL query to find all duplicate emails in a table namedPerson.+----+---------+| Id | Email |+----+---------+| 1 | a@b.com || 2 | c@d.com || 3 | a@b.com |+----+---------+For e...原创 2019-03-13 21:39:06 · 244 阅读 · 0 评论 -
【sql学习】LeetCode之181. Employees Earning More Than Their Managers
TheEmployeetable holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.+----+-------+--------+-----------+| Id | Name | Salary | ...原创 2019-03-13 20:39:02 · 168 阅读 · 0 评论 -
【sql学习】LeetCode之175. Combine Two Tables
Table:Person+-------------+---------+| Column Name | Type |+-------------+---------+| PersonId | int || FirstName | varchar || LastName | varchar |+-------------+---------+Pe...原创 2019-03-20 23:25:19 · 235 阅读 · 0 评论 -
【sql学习】LeetCode之196. Delete Duplicate Emails
Write a SQL query todeleteall duplicate email entries in a table namedPerson, keeping only unique emails based on itssmallestId.+----+------------------+| Id | Email |+----+------...原创 2019-03-17 13:27:06 · 251 阅读 · 0 评论 -
【sql学习】LeetCode之183. Customers Who Never Order
Suppose that a website contains two tables, theCustomerstable and theOrderstable. Write a SQL query to find all customers who never order anything.Table:Customers.+----+-------+| Id | Name ...原创 2019-03-17 13:17:22 · 231 阅读 · 0 评论 -
【sql学习】LeetCode之197. Rising Temperature
Given aWeathertable, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates.+---------+------------------+------------------+| Id(INT) | Re...原创 2019-03-19 20:24:12 · 204 阅读 · 0 评论 -
【sql学习】LeetCode之176. Second Highest Salary
Write a SQL query to get the second highest salary from theEmployeetable.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+For exam...原创 2019-03-09 22:23:46 · 223 阅读 · 0 评论 -
【sql学习】基础知识
2019/03/09 -- sql必知必会order by:1)使用order by 列名1,进行排序(默认是升序排列)2)可以使用order by 列名1, 列名2; 则是先根据列名1排序,列名1相同的,再根据列名2进行排序3)可以使用order by 列名1 desc, 列名2 desc; 来降序排列,让最大的排在表的第一行4)order by语句,必须是select语句...原创 2019-03-09 21:24:36 · 141 阅读 · 0 评论 -
【sql学习】之EXISTS
SQL中EXISTS的用法 一种通俗的可以理解为:将外查询表的每一行,代入内查询作为检验,如果内查询返回的结果取非空值,则EXISTS子句返回TRUE,这一行行可作为外查询的结果行,否则不能作为结果。https://www.cnblogs.com/netserver/archive/2008/12/25/1362615.htmlSQL 子查询 EXISTS 和...转载 2019-01-21 21:10:19 · 727 阅读 · 0 评论