Mega Code Archive

 
Categories / MSSQL Tutorial / Query
 

IS NULL and = NULL

4> 5> CREATE TABLE titleauthor( 6>    au_id          varchar(20), 7>    title_id       varchar(20), 8>    au_ord         tinyint               NULL, 9>    royaltyper     int                   NULL 10> ) 11> GO 1> 2> insert titleauthor values(null, '2', 1, 60) 3> insert titleauthor values('2', '3', 1, 100) 4> insert titleauthor values('3', '4', 1, 100) 5> insert titleauthor values('4', '5', 1, 100) 6> insert titleauthor values('5', '6', 1, 100) 7> insert titleauthor values('6', '7', 2, 40) 8> insert titleauthor values('7', '8', 1, 100) 9> insert titleauthor values('8', '9', 1, 100) 10> GO (1 rows affected) (1 rows affected) (1 rows affected) (1 rows affected) (1 rows affected) (1 rows affected) (1 rows affected) (1 rows affected) 1> 2> select * from titleauthor where au_id is null; 3> GO au_id                title_id             au_ord royaltyper -------------------- -------------------- ------ ----------- NULL                 2                         1          60 (1 rows affected) 1> select * from titleauthor where au_id = null; 2> GO au_id                title_id             au_ord royaltyper -------------------- -------------------- ------ ----------- (0 rows affected)