Database: SELECT Rows - Introduction
The SELECT
command can be used with one table to select
rows that meet some criterion for the resulting table. This uses the
Student table.
The FROM
clause specified the table(s) and the
WHERE
clause specifies conditions that a row must
satisfy to be included in the result.
Selecting rows with arithmetic comparison
To get all students with a GPA greater than or equal to 3.0.
SELECT *
FROM Student
WHERE student_gpa >= 3.0;
Result:
4 | Minnie | Mouse | 3.8 |
3 | Peter | Rabbit | 3.6 |
There may even be no results. For example,
SELECT *
FROM Student
WHERE student_gpa >= 4.0;
Result:
Nothing is selected.
Selecting columns and rows
Column selections and comparisons can both be done. The result doesn't have to
display columns that were compared.
SELECT student_lname, student_fname
FROM Student
WHERE student_gpa >= 3.0;
Result: