Often, you are interested in only columns in a table. For example, to make up birthday cards for employees you might want to see the Surname, DepartmentID and BirthDate columns.
In this section, you will select each employee's birth date, last name, and department ID. Type the following:
SELECT Surname, DepartmentID, BirthDate FROM Employees
Surname |
DepartmentID |
BirthDate |
---|---|---|
Whitney |
100 |
1958-06-05 |
Cobb |
100 |
1960-12-04 |
Chin |
200 |
1966-10-30 |
Jordan |
300 |
1951-12-13 |
Breault |
100 |
1947-05-13 |
The three columns appear in the order in which you typed them in the SELECT command. To rearrange the columns, simply change the order of the column names in the command. For example, to put the BirthDate column on the left, use the following command:
SELECT BirthDate, Surname, DepartmentID FROM Employees
You can order rows and look at only certain columns at the same time as follows:
SELECT BirthDate, Surname, DepartmentID FROM Employees ORDER BY Surname
The asterisk in
SELECT * FROM Employees
is a short form for all columns in the table.
Queries involving columns that have a significant number of NULL values run faster than in previous releases. The process of inserting or updating data in a table, however, may take longer (compared with previous releases) in cases where a significant number of NULL values are being inserted into the table.