SQL NULL Values
SQL NULL Values
NULL Values
The field with no value contains null value. It has differences from a field with zero value or field that has
spaces. It is a field that is left blank during the creation of the record. Comparison operators are used to
test null values. These operators are: =, <, != etc. In SQL, IS NULL , NOT NULL operators are used.
However there is an operator IS NULL which is used to test null values or empty values. In reverse, the
IS NOT NULL operator is used to test non-empty values.
IS NULL Syntax:
SELECT column_names
FROM table_name
WHERE column_name IS NULL;
IS NOT NULL Syntax:
SELECT column_names
FROM table_name
WHERE column_name IS NOT NULL;
SQL UPDATE Statement
In order to modify existing records in a table, the UPDATE statement is used. It is necessary to be caution
while updating the table. You need to be careful using the WHERE clause. What the clause is specifying
need to be checked. All records in the table will be updated if the where clause in omitted. The WHERE
clause also determines how many records will be updated.
UPDATE Syntax:
UPDATE table_name
SET column1 = value1, column2 = value2,...
WHERE condition;
SQL DELETE Statement
In order to delete an existing record in a table, the DELETE statement is used. The WHERE clause
specifies which statement should be deleted. If the WHERE clause is omitted all records in the table will
be deleted.
DELETE Syntax:
DELETE FROM table_name WHERE condition;
In order to delete all rows the following syntax is used.
DELETE FROM table_name;