1.在from子句中包含多个表名时,必须选择记录条数最少的表作为基础表:若有三个以上的表连接查询,那就需要选择交叉表作为基础表,交叉表指被其他表引用的表. 2.使用exists代替in.使用not exists 代替not in. 高效:SELECT * FROM EMP (基础表) WHERE EMPNO > 0 AND EXISTS (SELECT 'X' ROM DEPT WHERE DEPT.DEPTNO = EMP.DEPTNO AND LOC = 'MELB') 低效:SEL
1.配电gis线路导出数据: select r.name 线路名称,r.run_status 运行状态,r.voltage_level 电压等级,r.manager_depart 管理部门,r.belong_substation 所属厂站 from ods_sc.T_D2_PD_FEEDER r where r.gsdm='040100' and r.run_status <>'退运' and r.voltage_level='10kV'and r.manager_depart not in
create view dbo.V_ZDUser_DDasselect * from dbo.V_ZDUser_DD1 union all select * from dbo.V_ZDUser_DD2 union all select * from dbo.V_ZDUser_DD3 union all select * from dbo.V_ZDUser_DD4 union all select * from dbo.V_ZDUser_DD5;
1. 从SqlSessionDaoSupport开始 通常我们使用MyBatis会让自己的DAO继承SqlSessionDaoSupport,那么SqlSessionDaoSupport是如何运作的呢,下面是SqlSessionDaoSupport的源代码 /* * Copyright 2010 The myBatis Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may n
Entity Framework为我们提供了很大的方便,但有时候,我们想看看EF生成的Sql语句到底是怎样的,一种方式是我们可以启用Sql Server Profer工具.今天介绍另外一种方式,非常简单,可以监听EF执行的每条Sql语句,而且也可以自定义在执行语句前,执行语句完成后的动作.通过这种方式也可以非常方便的去监听系统的运行日志. 完成这个功能,需要引入二个第三方的组件,分别是Clutch.dll和Clutch.Diagnostics.Enti