W3. SQL Null Values Flashcards
Q: What is a NULL value in SQL?
A: A field with no value, meaning it was left blank during record creation.
Q: How is a NULL value different from a zero or a space?
A: NULL represents an absence of value, while zero and space are actual values.
Q: How do you test for NULL values in SQL?
A: Use the IS NULL or IS NOT NULL operators.
Q: What is the syntax for using the IS NULL operator?
SELECT column_names
FROM table_name
WHERE column_name IS NULL;
Q: Write a query to select customers with a NULL value in the “Address” field.
SELECT CustomerName, ContactName, Address FROM Customers WHERE Address IS NULL;
Q: Why can’t you use = or <> to test for NULL values?
A: Because NULL represents an absence of value and cannot be compared directly with comparison operators.
Q: What does the IS NOT NULL operator do?
A: It tests for non-empty values, returning records where the specified field is not NULL.
Q: Write a query to select customers with a value in the “Address” field.
SELECT CustomerName, ContactName, Address FROM Customers WHERE Address IS NOT NULL;