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! Link to comment https://forums.phpfreaks.com/topic/20520-i-need-help-with-i-think-should-be-a-pretty-simple-query/ 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 = '' Link to comment https://forums.phpfreaks.com/topic/20520-i-need-help-with-i-think-should-be-a-pretty-simple-query/#findComment-90492 Share on other sites More sharing options...
Gmunky Posted September 12, 2006 Author Share Posted September 12, 2006 ha. thanks! Link to comment https://forums.phpfreaks.com/topic/20520-i-need-help-with-i-think-should-be-a-pretty-simple-query/#findComment-90493 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? Link to comment https://forums.phpfreaks.com/topic/20520-i-need-help-with-i-think-should-be-a-pretty-simple-query/#findComment-90494 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] Link to comment https://forums.phpfreaks.com/topic/20520-i-need-help-with-i-think-should-be-a-pretty-simple-query/#findComment-90498 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 != '' Link to comment https://forums.phpfreaks.com/topic/20520-i-need-help-with-i-think-should-be-a-pretty-simple-query/#findComment-90509 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.