Updating to a NULL Value

From InterBase
Jump to: navigation, search

Sometimes data needs to be updated before all the new values are available. You can indicate unknown data by setting values to NULL. This works only if a column is nullable, meaning that it is not defined as NOT NULL. Suppose that in the previous example, the department number of salespeople hired before 1992 is changing but the new number is not yet known. You would update salaries and department numbers as follows:

UPDATE Employee
SET salary = salary + 2000, dept_no = NULL
WHERE job_code = 'Sales'
AND hire_date < '01-Jan-1992'

Advance To

Using a Subquery to Update