Limiting the Database Records Retrieved

A simple query retrieves all of the records in the table(s). Most queries require the developer to identify conditions that limit the records retrieved by the SELECT statement. These conditions are placed in the WHERE clause. Listing 4.6 illustrates a query of the Employee table that retrieves only the employee records for the Welfare department.

Listing 4.6. Using the WHERE Clause to Select Welfare Department Employees
 SQL> select fk_department, last_name, first_name 2 from employee 3 where fk_department = 'WEL'; FK_D LAST_NAME FIRST_NAME ---- --------------- --------------- WEL HOOVER HERBERT WEL TAFT WILLIAM WEL ANTHONY SUSANNE WEL ROOSEVELT ELEANOR WEL REAGAN RONALD WEL CARTER JIMMY 6 rows selected. ...

Get Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.