mysql数据库中is null语句的用法
注意在mysql中,0或 null意味着假而其它值意味着真。布尔运算的默认真值是1。
对null的特殊处理即是在前面的章节中,为了决定哪个动物不再是活着的,使用death is not null而不使用death != null的原因。
在group by中,两个null值视为相同。
执行order by时,如果运行 order by ... asc,则null值出现在最前面,若运行order by ... desc,则null值出现在最后面。
null操作的常见错误是不能在定义为not null的列内插入0或空字符串,但事实并非如此。在null表示"没有数值"的地方有数值
。使用is [not] null则可以很容易地进行测试
is null or = null
mysql>
mysql> create table topic(
-> topicid smallint not null auto_increment primary key,
-> name varchar(50) not null,
-> instock smallint unsigned not null,
-> onorder smallint unsigned not null,
-> reserved smallint unsigned not null,
-> department enum('classical', 'popular') not null,
-> category varchar(20) not null,
-> rowupdate timestamp not null
-> );
query ok, 0 rows affected (0.02 sec)
mysql>
mysql>
mysql> insert into topic (name, instock, onorder, reserved, department, category) values
-> ('java', 10, 5, 3, 'popular', 'rock'),
-> ('css', 10, 5, 3, 'classical', 'opera'),
-> ('c sharp', 17, 4, 1, 'popular', 'jazz'),
-> ('c', 9, 4, 2, 'classical', 'dance'),
-> ('c++', 24, 2, 5, 'classical', 'general'),
-> ('perl', 16, 6, 8, 'classical', 'vocal'),
-> ('python', 2, 25, 6, 'popular', 'blues'),
-> ('php', 32, 3, 10, 'popular', 'jazz'),
-> ('asp.net', 12, 15, 13, 'popular', 'country'),
-> ('vb.net', 5, 20, 10, 'popular', 'new age'),
-> ('vc.net', 24, 11, 14, 'popular', 'new age'),
-> ('uml', 42, 17, 17, 'classical', 'general'),
-> ('www.java2s.com',25, 44, 28, 'classical', 'dance'),
-> ('oracle', 32, 15, 12, 'classical', 'general'),
-> ('pl/sql', 20, 10, 5, 'classical', 'opera'),
-> ('sql server', 23, 12, 8, 'classical', 'general');
query ok, 16 rows affected (0.00 sec)
records: 16 duplicates: 0 warnings: 0
mysql>
mysql> select * from topic;
+---------+----------------+---------+---------+----------+------------+----------+---------------------+
| topicid | name | instock | onorder | reserved | department | category | rowupdate |
+---------+----------------+---------+---------+----------+------------+----------+---------------------+
| 1 | java | 10 | 5 | 3 | popular | rock | 2007-07-23 19:09:45 |
| 2 | javascript | 10 | 5 | 3 | classical | opera | 2007-07-23 19:09:45 |
| 3 | c sharp | 17 | 4 | 1 | popular | jazz | 2007-07-23 19:09:45 |
| 4 | c | 9 | 4 | 2 | classical | dance | 2007-07-23 19:09:45 |
| 5 | c++ | 24 | 2 | 5 | classical | general | 2007-07-23 19:09:45 |
| 6 | perl | 16 | 6 | 8 | classical | vocal | 2007-07-23 19:09:45 |
| 7 | python | 2 | 25 | 6 | popular | blues | 2007-07-23 19:09:45 |
| 8 | php | 32 | 3 | 10 | popular | jazz | 2007-07-23 19:09:45 |
| 9 | asp.net | 12 | 15 | 13 | popular | country | 2007-07-23 19:09:45 |
| 10 | vb.net | 5 | 20 | 10 | popular | new age | 2007-07-23 19:09:45 |
| 11 | vc.net | 24 | 11 | 14 | popular | new age | 2007-07-23 19:09:45 |
| 12 | uml | 42 | 17 | 17 | classical | general | 2007-07-23 19:09:45 |
| 13 | www.java2s.com | 25 | 44 | 28 | classical | dance | 2007-07-23 19:09:45 |
| 14 | oracle | 32 | 15 | 12 | classical | general | 2007-07-23 19:09:45 |
| 15 | pl/sql | 20 | 10 | 5 | classical | opera | 2007-07-23 19:09:45 |
| 16 | sql server | 23 | 12 | 8 | classical | general | 2007-07-23 19:09:45 |
+---------+----------------+---------+---------+----------+------------+----------+---------------------+
16 rows in set (0.00 sec)
mysql>
mysql>
mysql> select name, department, category
-> from topic
-> where category is null
-> order by name;
empty set (0.00 sec)
mysql>
mysql>
mysql>
mysql> select name, department, category
-> from topic
-> where category = null
-> order by name;
empty set (0.00 sec)
mysql>
mysql>
mysql> drop table topic;
query ok, 0 rows affected (0.00 sec)
<=>null: null不等空
null意味着“没有值”或www.3ppt.com“未知值”,且它被看作与众不同的值。为了测试null,你不能使用算术比较 操作符例如=、<或!=
mysql>
mysql> select name, department, category
-> from topic
-> where category<=>null
-> order by name;
empty set (0.00 sec)
mysql>
mysql> drop table topic;
query ok, 0 rows affected (0.02 sec)
is not null
mysql> select name, department, category
-> from topic
-> where category is not null
-> order by name;
+----------------+------------+----------+
| name | department | category |
+----------------+------------+----------+
| asp.net | popular | country |
| c | classical | dance |
| c sharp | popular | jazz |
| c++ | classical | general |
| java | popular | rock |
| javascript | classical | opera |
| oracle | classical | general |
| perl | classical | vocal |
| php | popular | jazz |
| pl/sql | classical | opera |
| python | popular | blues |
| sql server | classical | general |
| uml | classical | general |
| vb.net | popular | new age |
| vc.net | popular | new age |
| www.java2s.com | classical | dance |
+----------------+------------+----------+
16 rows in set (0.00 sec)
mysql>
mysql> drop table topic;
query ok, 0 rows affected (0.00 sec)
is,null
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新动态
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]