SQL Server2005中IN运算的一个错误
2008-04-25 19:50
197 查看
/**//*
测试in运算容易出错的一种情况,就是在子查询中的查询列实际不存在,会返回所有数据
*/
create table t_1(uid int)
create table t_2(id int)
insert into t_1
select 1
union all
select 2
union all
select 3
union all
select 4
insert into t_2
select 1
union all
select 2
union all
select 7
union all
select 8
select * from t_1 where uid in (select [uid] from t_2 where id like '[0-9]')
drop table t_1,t_2
/**//*
从例子中能够看出,子查询中如果使用本来不存在的列,如果编译没报错的话,查询的结果是错误的,并且不会有任何提示。还有就是子查询中的这个列名,并不是随便写就行,要重现这个错误,需要这个列名在t_1表中存在。
当然,如果单独执行select [user_id] from t_2 where id like '[0-9]' ,就会报错:
消息207,级别16,状态1,第26 行
列名'user_id' 无效。
*/
相关文章推荐
- 解决drupal的模块状态过多会导致启用模块时候出现一个类似错误Maximum execution time of 30 seconds exceeded in xxxxxxxxxxx
- maven安装jar包到本地仓库报的一个错误:Could not find goal '' in plugin org.apache.maven.plugins
- IIS ftp:home directory inaccessible错误问题的一个解除方法
- 一个奇葩错误:Invalid update: invalid number of rows in section 0
- IAR的一个编译错误Error[e27]: Entry "GenericApp_Init::?relay" in module Coordinator
- Uboot编译出下如下错误的一个原因:In function `__aeabi_ldiv0': (.text+0x8): undefined reference to `raise'
- IAR的一个编译错误Error[e27]: Entry "GenericApp_Init::?relay" in module Coordinator
- 记一个程序编译错误: warning: missing sentinel in function call [-Wformat]
- AfxoleInit()的一个错误(oleinit.cpp第54行)的简要分析
- 一个奇葩错误:Invalid update: invalid number of rows in section 0
- junit in action (估计是第一版的)的一个错误中文版P145
- 为什么word in list 会返回错误呢?
- C# 一步一步完成一个简单的计算器 第二步---实现单目运算
- C++在写静态变量时容易犯的一个小错误
- 记录一个QScopedPointer forward declared 的编译错误
- 我犯了一个错误,您能指出吗?
- Appache 无法启动,检查 wamp “appache_error.log”文件,发现错误 (OS 10022)提供了一个无效的参数
- 启动Tomcat服务器,报Address already in use: JVM_Bind<null>:8080的错误
- Error occurred in deployment step 'Add Solution': 此解决方案包含面向全局程序集缓存的一个或多个程序集。您应该为将保存在全局程序集缓存中的任何程序集使用
- 犯了一个严重的错误