有个两条select 哪个查询的效率高?
表:
审核表:
create table T_Auditing
(
F_TableName varchar(10) not null,
F_CustNo Varchar(15) not null,
F_SN integer default 0 not null,
F_Time smalldatetime default GetDate() not null,
F_assessor varchar(12) not null,
F_Result varchar(10) not null
primary key (F_TableName,F_CustNo,F_SN)
)
缴费表:
create table T_IncrementFee
(
F_CustNO varchar(15) not null,
F_SN integer not null default 1,
F_FeeItem varchar(20) Foreign key references T_ServeItem(F_FeeItem) not null,
F_Money money not null default 0,
F_GatheringDate smalldatetime not null default GetDate(),
F_Payee varchar(20) Foreign key references T_Personnel(F_name) not null,
F_Invoice varchar(12) not null default '00000000000',
F_Remark varchar(200)
primary key (F_custNO,F_SN)
)
A与B有个两条select 哪个查询的效率高?
A:
select TI.*,TA.* from T_IncrementFee TI,(select * from T_Auditing where F_TableName='初装费')
TA where TI.F_CustNo<>Ta.F_CustNo and TI.F_SN<>TA.F_SN
B:
select * from T_IncrementFee TI where TI.F_CustNo
not in(select F_CustNo from T_Auditing TA where TA.F_Tablename='初装费' and TA.F_SN=TI.F_SN)
and Ti.F_SN not in(select F_SN from T_Auditing TA where TA.F_Tablename='初装费' and TA.F_SN=TI.F_SN)
审核表:
create table T_Auditing
(
F_TableName varchar(10) not null,
F_CustNo Varchar(15) not null,
F_SN integer default 0 not null,
F_Time smalldatetime default GetDate() not null,
F_assessor varchar(12) not null,
F_Result varchar(10) not null
primary key (F_TableName,F_CustNo,F_SN)
)
缴费表:
create table T_IncrementFee
(
F_CustNO varchar(15) not null,
F_SN integer not null default 1,
F_FeeItem varchar(20) Foreign key references T_ServeItem(F_FeeItem) not null,
F_Money money not null default 0,
F_GatheringDate smalldatetime not null default GetDate(),
F_Payee varchar(20) Foreign key references T_Personnel(F_name) not null,
F_Invoice varchar(12) not null default '00000000000',
F_Remark varchar(200)
primary key (F_custNO,F_SN)
)
A与B有个两条select 哪个查询的效率高?
A:
select TI.*,TA.* from T_IncrementFee TI,(select * from T_Auditing where F_TableName='初装费')
TA where TI.F_CustNo<>Ta.F_CustNo and TI.F_SN<>TA.F_SN
B:
select * from T_IncrementFee TI where TI.F_CustNo
not in(select F_CustNo from T_Auditing TA where TA.F_Tablename='初装费' and TA.F_SN=TI.F_SN)
and Ti.F_SN not in(select F_SN from T_Auditing TA where TA.F_Tablename='初装费' and TA.F_SN=TI.F_SN)
...全文
相关推荐
MySQL实现递归查询的三种方式.rar
### 方式二:纯SQL实现不使用自定义函数,我们可以利用嵌套的SELECT语句和JOIN来模拟递归。这通常涉及到多次查询和连接同一张表。
mssql insert into 和insert into select性能比较
**INSERT INTO SELECT** - `INSERT INTO SELECT`语句允许从一个或多个表或查询中选择数据并插入到另一个表中。
用SQL语句查询数据库中某一字段下相同值的记录方法
以下是两种查询数据库中某一字段下相同值的记录的方法。**方法一:通过学号和身份证字段来查询**这种方法推荐用于数据库执行效率高的场景。
SQLserver2008查询性能优化
总的来说,SQL Server 2008查询性能优化涉及多个方面,包括但不限于索引的设计和管理、查询优化、资源使用监控等。正确地应用这些策略,将有助于构建一个响应迅速、效率高的数据库系统。
JAVA的多条件模糊查询
, int age) { List<Map<String, Object>> list = null; String sql = "SELECT * FROM users WHERE 1=1"; List


应用实例
