SQLite: IS NOT NULL
This SQLite tutorial explains how to use the SQLite IS NOT NULL condition with syntax and examples.
Description
The SQLite IS NOT NULL condition is used to test for a NOT NULL value in a SELECT, INSERT, UPDATE, or DELETE statement.
Syntax
The syntax for the IS NOT NULL Condition in SQLite is:
expression IS NOT NULL
Parameters or Arguments
- expression
- The expression to test whether it is a NOT NULL value.
Note
- If expression is NOT a NULL value, the condition evaluates to TRUE.
- If expression is a NULL value, the condition evaluates to FALSE.
Example - With SELECT Statement
Here is an example of how to use the SQLite IS NOT NULL condition in a SELECT statement:
SELECT * FROM employees WHERE employee_id IS NOT NULL;
This SQLite IS NOT NULL example will return all records from the employees table where the employee_id does not contain a null value.
Example - With INSERT Statement
Here is an example of how to use the SQLite IS NOT NULL condition in an INSERT statement:
INSERT INTO temp (temp_employee_id, temp_last_name, temp_first_name) SELECT employee_id, last_name, first_name FROM employees WHERE last_name IS NOT NULL;
This SQLite IS NOT NULL example will insert records into the temp table where the last_name does not contain a null value.
Example - With UPDATE Statement
Here is an example of how to use the SQLite IS NOT NULL condition in an UPDATE statement:
UPDATE employees SET status = 'Active' WHERE department IS NOT NULL;
This SQLite IS NOT NULL example will update records in the employees table and set the status to 'Active' where the department does not contain a null value.
Example - With DELETE Statement
Here is an example of how to use the SQLite IS NOT NULL condition in a DELETE statement:
DELETE FROM employees WHERE termination_date IS NOT NULL;
This SQLite IS NOT NULL example will delete all records from the employees table where the termination_date does not contain a null value.
Advertisements