Mysql面试相关

2020-10-31  本文已影响0人  缘尤会

Mysql索引 用还是不用

索引的种类

  1. 从功能逻辑上分为:
  1. 按照物理实现方式:
  1. 按字段个数进行划分:

mysql 日志

一般会设置慢查询日志。

mysql 思维训练

  1. 实现select 取行号
select  p.name, p.type, p.view, @row_num:=@row_num+1 as row_num from  products a , (select  @row_num:=0) b  order by p_view 
  1. 对每个分组排序,并取出前n个
SELECT p_type, p_name, p_view, row_num from(
SELECT p_type, p_name, p_view IF(@bak=p_type,@row_num:=row_num+1,@row_num:=1) as row_num, @bak:=p_type 
from
(SELECT p_type, p_name, p_view from products 
ORDER BY p_type, p_view desc ) a,(SELECT @row_num:=0,@bak:=' ’)b ) c
where c.row_num <2
上一篇 下一篇

猜你喜欢

热点阅读