|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Checking for null values
Hi everyone! I just have a simple question. How do you check for null values in SQL? I tried it like this but I know this is wrong:
Select Car_Number, Car_Payment From Car Where Car_Payment NOT Null; I basically want to display the car number and car payment columns but only those rows that have a car payment. Anybody know the syntax for this? Thanks in advance. ![]() |
|
#2
|
||||
|
||||
|
Good database design doesn't allow for NULL values.
Allowing a database to contain NULL values severly hinders query performance. All fields in the database should have default values. These default values are implicityly entered into the database fields, when no value was passed. If CarPayment is a money (number field), then it's default value should be 0.00. Then your sql statement would be like this Code:
Select Car_Number, Car_Payment From Car Where Car_Payment <> 0.00; |
|
#3
|
||||
|
||||
|
Hey thanks a lot! Worked like a charm. Oh just so you know I'm not developing a database. I just needed to know this for school. I'm answering questions by running SQL queries. Thanks!
![]() |
|
#4
|
||||
|
||||
|
lol...You should inform your instructor that allowing NULL values in a database is bad design, then explain to him/her that it slows down query processing performance, because additional calculations must be performed by the database to deal with NULL values in a field.
Share it with your classmates as well. They'll have some inside (not taught in school) knowledge about database design. |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Checking for null values |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|