sql求解

blackhero 2005-02-17 01:43:08
select top 10000 * from VIEW_ALMEVT0501 where ( evtdate>='2005-01-17' and evtdate<='2005-02-17' and ActID like '%00%' ) and actid in( select actid from view_usract where property='注册' )
union
select top 10000 * from VIEW_ALMEVT0502 where ( evtdate>='2005-01-17' and evtdate<='2005-02-17' and ActID like '%00%' ) and actid in( select actid from view_usract where property='注册' )
order by
EVTDATE desc,EVTTIME desc
这个sql语句.是两个表,我想去掉union,where后再加上AlmID=@AlmID
表VIEW_ALMEVT0501,VIEW_ALMEVT0502

Thanks
...全文
124 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
amendajing 2005-02-18
  • 打赏
  • 举报
回复
楼主可以在查询分析起里执行sql语句,发现错误可以及时纠正
blackhero 2005-02-18
  • 打赏
  • 举报
回复
自己顶一下
blackhero 2005-02-17
  • 打赏
  • 举报
回复
如果有四个表VIEW_ALMEVT0501,VIEW_ALMEVT0502,VIEW_ALMEVT0503,VIEW_ALMEVT0504.
每个表中的记录很多.
select top 10000 * from (select * from VIEW_ALMEVT0501 where ( evtdate>='2005-01-17' and evtdate<='2005-02-17' and ActID like '%00%' ) and actid in( select actid from view_usract where property='注册' )
union
select * from VIEW_ALMEVT0502 where ( evtdate>='2005-01-17' and evtdate<='2005-02-17' and ActID like '%00%' ) and actid in( select actid from view_usract where property='注册' )
) C
order by
EVTDATE desc,EVTTIME desc
这种方种查询的.是不是很慢.性能怎么样.
anmeier 2005-02-17
  • 打赏
  • 举报
回复
不加where 也对,支持dangxuehua(绿海红浪)的方法
blackhero 2005-02-17
  • 打赏
  • 举报
回复
select top 10000 * from (
select top 10000 * from VIEW_ALMEVT0501 where ( evtdate>='2005-01-17' and evtdate<='2005-02-17' and ActID like '%00%' ) and actid in( select actid from view_usract where property='注册' )
union
select top 10000 * from VIEW_ALMEVT0502 where ( evtdate>='2005-01-17' and evtdate<='2005-02-17' and ActID like '%00%' ) and actid in( select actid from view_usract where property='注册' )
) C
order by
EVTDATE desc,EVTTIME desc

我不加where对不对呀
-------blackhero--
dangxuehua 2005-02-17
  • 打赏
  • 举报
回复
select top 10000 from (
select top 10000 * from VIEW_ALMEVT0501 where ( evtdate>='2005-01-17' and evtdate<='2005-02-17' and ActID like '%00%' ) and actid in( select actid from view_usract where property='注册' )
union
select top 10000 * from VIEW_ALMEVT0502 where ( evtdate>='2005-01-17' and evtdate<='2005-02-17' and ActID like '%00%' ) and actid in( select actid from view_usract where property='注册' )
) C
where AlmID=@AlmID
order by
EVTDATE desc,EVTTIME desc
zhijianshadog 2005-02-17
  • 打赏
  • 举报
回复
楼主是不是数据库结构设计的不对,想用软件方法来实现对不对?
hedonister 2005-02-17
  • 打赏
  • 举报
回复
晕,你是什么意思?要干什么?
blackhero 2005-02-17
  • 打赏
  • 举报
回复
自己顶一下

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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