路过的高手,帮忙优化一下SQL语句

andylyc 2008-01-17 10:52:29
select *
from att_idcard a
where a.in_out='E'
and to_char(input_time,'yyyymmdd')='20080117'
and not exists (
select id_card
from emp_master b
where b.id_card=a.card_id
and b.status in ('P','W')
)

以上脚本执行比较慢,望高手帮助优化一下。
...全文
69 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
昵称被占用了 2008-01-17
  • 打赏
  • 举报
回复
select   * 
from att_idcard a
where a.in_out='E'
and input_time>='2008-01-17'
and input_time<'2008-01-18'
and not exists (
select 1
from emp_master b
where b.id_card=a.card_id
and b.status in ('P','W')
)

--or :

select a.*
from att_idcard a left join emp_master b
on b.id_card=a.card_id
and b.status in ('P','W')
where b.id_card is null
and a.in_out='E'
and input_time>='2008-01-17'
and input_time<'2008-01-18'
-狙击手- 2008-01-17
  • 打赏
  • 举报
回复
列上尽是不要用函数


是否有索引 ?
ORARichard 2008-01-17
  • 打赏
  • 举报
回复
这根本就是ORACLE的查询,怎么问到这来了。

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧