请问各位大侠:
如下语句应该如何优化好呢?
select year,name,address from tb where year in('1912','1915','1916','1918');
我的数据库是sql server 2005
如下语句应该如何优化好呢?
select year,name,address from tb where year in('1912','1915','1916','1918');
我的数据库是sql server 2005
解决方案 »
- 大家帮下,有关文件复制到其他主机
- 会创建app.config文件并会将数据库连接字符串写进去的高手帮帮忙!
- 高难度问题,如果装载webform的设计器
- 关于“.Net精简框架”的模拟键盘问题--100分
- 用DataGridView绑定数据集数据后,如何获取当前选中的数据?
- VISIO STDIO.NET2003开发环境,C#语言.实时数据动态显示--折线图
- 如何全局获得鼠标移动,点击之类的消息
- 怎么把dataset的值直接插入oracle数据库,急!!在线等!
- 应用程序正初始化失败(0xc0000135)
- 请教一个问题??急
- 读取xml 对比md5问题
- WinForm DataGridView控件如何做到Excel这种筛选? [图]
select * from A where exists(select b from B where b=A.b)
union all
select year,name,address from tb where year='1915'
union all
select year,name,address from tb where year='1916'
union all
select year,name,address from tb where year='1918'
是在不行拼 AND / OR 也比IN快,当然是在数据量大的轻快下,小数据量看不出来
select year,name,address from tb where
year='1912'
or year='1915'
or year='1916'
or year='1918'
select year,name,address from
(
select year,name,address from tb where
year='1912'
union
select year,name,address from tb where
year='1915'
union
select year,name,address from tb where
year='1916'
union
select year,name,address from tb where
year='1918'
)
select * from A where exists(select b from B where b=A.b)
也可以建个索引。