|
|
不知道在sql里头,有没有反选的东西。
比如select * from user where id = 1的时候
它会return select * from user where id <> 1的结果? |
|
|
|
|
|
|
|
|
|
|
发表于 23-11-2006 04:53 PM
|
显示全部楼层
原帖由 jesh 于 23-11-2006 04:41 PM 发表
不知道在sql里头,有没有反选的东西。
比如select * from user where id = 1的时候
它会return select * from user where id <> 1的结果?
SELECT * FROM user WHERE id Not In (SELECT * FROM user WHERE id=1) |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 23-11-2006 05:08 PM
|
显示全部楼层
|
感谢~ 如果有直接 !(select * from user where id = 1)会更好 |
|
|
|
|
|
|
|
|
|
|
发表于 24-11-2006 10:16 AM
|
显示全部楼层
直接这样
select * from user where id <> 1
不行吗? |
|
|
|
|
|
|
|
|
|
|
发表于 24-11-2006 06:25 PM
|
显示全部楼层
原帖由 hui_wooi 于 24-11-2006 10:16 AM 发表
直接这样
select * from user where id <> 1
不行吗?
楼主不是说"比如select * from user where id = 1的时候
它会return select * from user where id <> 1的结果?
"
就是在select * from user where id = 1 里加入一些statement然后出现 select * from user where id <> 1的结果.
不过这是多余的哈哈 |
|
|
|
|
|
|
|
|
|
|
发表于 28-11-2006 11:03 PM
|
显示全部楼层
原帖由 max5007 于 24-11-2006 06:25 PM 发表
楼主不是说"比如select * from user where id = 1的时候
它会return select * from user where id <> 1的结果?
"
就是在select * from user where id = 1 里加入一些statement然后出现 ...
有时我们不运用 "where id <> 1" 是因为执行问题(performance issue).
不同的database optimizer 生产不同 execution plan.
许多的developer 不看execution plan.
我不是developer  |
|
|
|
|
|
|
|
|
|
|
发表于 28-11-2006 11:23 PM
|
显示全部楼层
原帖由 悠哉亭 于 28-11-2006 11:03 PM 发表
有时我们不运用 "where id <> 1" 是因为执行问题(performance issue).
不同的database optimizer 生产不同 execution plan.
许多的developer 不看execution plan.
我不是developer
哦?我还是第一次听到。
什么是不同的execution plan? |
|
|
|
|
|
|
|
|
|
|
发表于 29-11-2006 12:17 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 29-11-2006 01:21 PM
|
显示全部楼层
原帖由 悠哉亭 于 29-11-2006 12:17 PM 发表
抱歉我的中文造诣很烂,我是用字典来打中文.
打到天黑也打不出. 
什么是不同 execution plan, 你可以看 SQL tuning 的书.
什么是 execution plan, 你可以看 MS SQL online book.
不同版本的数据库服务 ...
呵呵,谢谢。
我想我明白你的意思。
就看上面的sql。
select一次总比select两次来得快。 |
|
|
|
|
|
|
|
|
|
|
发表于 14-5-2008 02:52 PM
|
显示全部楼层
|
select * from table where not id = 1 |
|
|
|
|
|
|
|
|
|
|
发表于 24-5-2008 12:56 PM
|
显示全部楼层
回复 8# 悠哉亭 的帖子
|
很惊讶你用一个小时来回复。我以前也是用两个小时来回老外的Email. |
|
|
|
|
|
|
|
|
|
|
发表于 20-6-2008 12:50 AM
|
显示全部楼层
原帖由 阿听海恩 于 14-5-2008 02:52 PM 发表 
select * from table where not id = 1
不是和<> 是一样的吗?? |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|