Gmunky Posted September 12, 2006 Share Posted September 12, 2006 How do i write a query that outputs all the records when a specified attribute is null?for instance, if the table looks like this:_______________________studentID | phone |--------------------------| 1 |111-111-1111 | 2 |222-222-2222 | 3 | | 4 | |--------------------------- I want to output all the studentIDs with no phone numbers.i tried SELECT studentID WHERE phone is NULL; but i get an empty set.Thanks for all your help! Quote Link to comment Share on other sites More sharing options...
.josh Posted September 12, 2006 Share Posted September 12, 2006 how about:select studentID from table where phone = '' Quote Link to comment Share on other sites More sharing options...
Gmunky Posted September 12, 2006 Author Share Posted September 12, 2006 ha. thanks! Quote Link to comment Share on other sites More sharing options...
Gmunky Posted September 12, 2006 Author Share Posted September 12, 2006 ok. how about if I want to output the studentID's that are NOT null? Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 12, 2006 Share Posted September 12, 2006 [code]SELECT * FROM tableName WHERE studentID IS NULL;[/code] Quote Link to comment Share on other sites More sharing options...
.josh Posted September 12, 2006 Share Posted September 12, 2006 [quote author=Gmunky link=topic=107792.msg432824#msg432824 date=1158076787]ok. how about if I want to output the studentID's that are NOT null?[/quote]select studentID from table where studentID != '' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.