目录 1 where 条件查询 between like not in 2 group by 分组 聚合函数:max min sum avg count 3 having 过滤 4 distinct 去重 5 order by 排序 6 limit 限制结果返回数量 7 正则 8 多表查询 子查询 0 准备代码 1 where 条件查询 准备代码在最下面 在使用MySQL select语句时,可以使用 WHERE 子句来指定查询条件,从 FROM 子句的中间结果中选取适当的数据行,达到数据过滤的…
mysql中in查询条件的时候,很多时候排序是不规则的,如何按照in里面的条件进行排序呢? mysql中给出了办法,在in后面加order by field,order by field的首个条件是按照哪个字段排序,然后把in里面的条件复制进去,就可以排序了,希望可以帮助大家! select * from service_type st where st.id in (5,9,7,10,8) order by field(id,5,9,7,10,8)…
order表: order type gmt_create type 取值: 0,1 其中0非常多,1非常少. 当查询条件里 select * from order where type=0 and gmt_create > '2017' limit 20; 由于海量数据,可能搜索1千 w 才能得到1个数据. 所以要得到20个可能就要 mysql 遍历完一个亿的数据. 这时候就要考虑如何用索引,一步步的查询. 一个方案是将原表分表. 根据 type 先分表. 直接分成两张表,而不是多加一个…