易截截图软件、单文件、免安装、纯绿色、仅160KB

请教一个SQL查询的写法 - MS-SQL Server / 基础类

类似下面的代码执行时间非常长,请问要怎样写才是正确的写法?


select * from a where a.字段1+a.字段2 not in (select b.字段1+b.字段2 from b) 

(实际上的应用情况是更多字段,更多的子查询,但症结就是慢在多字段的IN上面,其余的都非常快,唯一是用到
a.字段1+a.字段2 not in 的句时,就极慢!

向各位高手求助!



换not exists 试试


引用
SQL code
select * from a inner join b
on a.字段1+a.字段2 =b.字段1+b.字段2
where b.字段1 is null

这种写法看不懂?能这样写?

引用
换not exists 试试


字段个数并不是一样的,请问如何写。

SQL code:
select * from a inner join b
on checksum(a.字段1,....)=checksum(b.字段1,....)
where b.字段1 is null


引用

引用 2 楼 chuifengde 的回复:
SQL code
select * from a inner join b
on a.字段1+a.字段2 =b.字段1+b.字段2
where b.字段1 is null

这种写法看不懂?能这样写?


2楼和5楼都误把LEFT JOIN写成了INNER JOIN。

引用
SQL code
select * from a inner join b
on checksum(a.字段1,....)=checksum(b.字段1,....)
where b.字段1 is null


什么代码啊,这样写怎么行?
{{----


相关问答:

csv文件转换成sql导入到数据库,没有数据为何?

执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......

求一个SQL语句 - MS-SQL Server / 基础类

字段1,字段2.....字段N,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
想要的结果是:
1,Na ......

sql语句问题 - MS-SQL Server / 疑难问题

现在有一个部门表dept(部门名称,部门号。。)有一个人员表emp(姓名,人员编号,职位,薪资,部门)
emp表中的内容是这样的:
a 1 工程师 3000 软件部
b 2 普通员工 2000 硬件部
c 3 工程师 4000 硬件部
d ......

sql语句问题 - Java / Web 开发

select o_customer,o_price from orders having o_price >=avg(o_price)
select o_customer,o_price from orders where o_price >=(select avg(o_price) from orders)
我感觉没有区别啊,怎么在mysql会有 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号