ISYS 307: Database Development - Notes for Class 7
Final Exam
The final exam is due next week. You can find it here.
SQL
SELECT - Get data back from the database.
UPDATE - Modify data.
DELETE - Delete data.
INSERT - Create new data.
The SELECT Statement
SELECT * FROM student
SELECT first, last_name, gpa FROM student
Adding square brackets ensure that the field, and table, names are not
reserved words.
SELECT [first], [last_name], [gpa] FROM [student]
Select all students with a GPA greater than 2.0
SELECT first, last_name, gpa FROM student
WHERE gpa>2.0
Sort by GPA, lowest first
SELECT first, last_name, gpa FROM student
WHERE gpa>2.0
ORDER BY gpa
Sort by GPA, lowest last
SELECT first, last_name, gpa FROM student
WHERE gpa>2.0
ORDER BY gpa DESC
Sort by first name, then last name
SELECT first, last_name, gpa FROM student
WHERE gpa>2.0
ORDER BY last_name, first
Shorthand form of the previous SQL statement
SELECT first, last_name, gpa FROM student
WHERE gpa>2.0
ORDER BY 1, 2
