Tutorial by Examples

The syntax for filtering for NULL (i.e. the absence of a value) in WHERE blocks is slightly different than filtering for specific values. SELECT * FROM Employees WHERE ManagerId IS NULL ; SELECT * FROM Employees WHERE ManagerId IS NOT NULL ; Note that because NULL is not equal to anything, not ...
When creating tables it is possible to declare a column as nullable or non-nullable. CREATE TABLE MyTable ( MyCol1 INT NOT NULL, -- non-nullable MyCol2 INT NULL -- nullable ) ; By default every column (except those in primary key constraint) is nullable unless we explicitly set ...
Setting a field to NULL works exactly like with any other value: UPDATE Employees SET ManagerId = NULL WHERE Id = 4
For example inserting an employee with no phone number and no manager into the Employees example table: INSERT INTO Employees (Id, FName, LName, PhoneNumber, ManagerId, DepartmentId, Salary, HireDate) VALUES (5, 'Jane', 'Doe', NULL, NULL, 2, 800, '2016-07-22') ;

Page 1 of 1