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 先分表. 直接分成两张表,而不是多加一个…
2016-12-16 阅读项目代码时,在项目的xml文件中发现如下写法: SELECT student_user_id FROM tbr_student_class WHERE 1=1 <if test="@Ognl@isNotEmpty(classId)"> and class_id =#{classId} </if> <if test="@Ognl@isNotEmpty(stuId)"> and student_user_id…
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <…
task 是用户任务表,manageuser是用户表,以left join 为参考: 此时主表是task,三条sql语句:注意区别.第一句无筛选条件,第二句筛选条件在on后面,第三句sql的筛选语句放到where中 SELECT t.id,t.UseManage,u.ID,u.LoginName,u.UserType FROM dbo.Task t LEFT JOIN dbo.ManageUser u ON t.UseManage=u.ID 搜索结果如下 总结:where 会在最终结果中筛选,o…
1简单查询 select* from 表名 select name as“姓名”fromstu (把name改为名字) 2条件查询 where 后面跟条件 条件要写清楚 3模糊查询 like no like %代表任意多个字符 _代表一个字符 4排序查询 order by 字段 排序值 (desc降 asc升) 5范围查询 between....and... 6离散查询 in notin 7聚合查询 sun 求和 count数据条数 max最…
原文地址:exp导出一个表中符合查询条件的数据 作者:charsi 导出一个表中的部分数据,使用QUERY参数,如下导出select * from test where object_id>50000这个条件中的数据exp charsi/charsi@testdb tables=(TEST) query="'where object_id>50000'" file=aaa.dmp log=aaa.log 其他参数含义:GRANTS:指定是否导出对象的授权信息,默认参数为Y,…