菜鸟求救,求结果

[复制链接]
查看11 | 回复5 | 2012-1-4 11:51:22 | 显示全部楼层 |阅读模式
以下的null代表真的null
根据如下表的查询结果,那么以下语句的结果是SQL> select * from usertable;
USERID USERNAME
----------- ----------------
1 user1
2 null
3 user3
4 null
5 user5
6 user6
SQL> select * from usergrade;
USERID USERNAME GRADE
---------- ---------------- ----------
1 user1 90
2 null 80
7 user7 80
8 user8 90
执行语句:
语句1
select count(*) from usergrade where username not in (select username from usertable);
语句2
select count(*) from usergrade gwhere not exists
(select null from usertable t where t.userid=g.userid and t.username=g.username);
回复

使用道具 举报

千问 | 2012-1-4 11:51:22 | 显示全部楼层
你的问题是什么


回复

使用道具 举报

千问 | 2012-1-4 11:51:22 | 显示全部楼层
两条SQL语句的执行结果啊
回复

使用道具 举报

千问 | 2012-1-4 11:51:22 | 显示全部楼层
最关键是为什么,不懂啊
回复

使用道具 举报

千问 | 2012-1-4 11:51:22 | 显示全部楼层
两条语句的返回值都是2
回复

使用道具 举报

千问 | 2012-1-4 11:51:22 | 显示全部楼层
不都是2啊,你运行一次就知道了,第一个是null的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行