DML??”DATA MANIPULATION LANGUAGE
The first DML statement to learn is SELECT. The SELECT statement provides the means of retrieving
information from the database. It is a very flexible command with numberless variations and much to know
about using it.
In the simplest case, use SELECT to retrieve values for certain columns in a table, such as the Sname and
Major values in the Student table we created in the previous section:
SELECT Sname, Major FROM Student;
This statement will retrieve one row for each student and display the student??™s name and major.
One can also be selective about which rows one displays by adding a WHERE clause:
SELECT Sname
FROM Student
WHERE Major = 'Computer Science';
This statement, or query, will return the names of all Computer Science majors, and no others.
If one wants to retrieve all columns for each qualifying row, one can use the asterisk to specify that all
columns be displayed:
SELECT *
FROM Student
WHERE Major = 'Computer Science';
The WHERE clause itself is very flexible. In addition to the equal sign, one can use the comparison and
logical operators given in Table 8-1.
Suppose one wants to find all the students named Jones who are not math or computer science majors, and
who live in either Williams or Schoelkopf dormitory.
Pages:
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418