Introduction to NonStop SQL/MP
Querying the Database
How to Use NonStop SQL
113425 Tandem Computers Incorporated 2–3
Suppose you want to know the names and employee numbers of all employees who
work in department 4000. To answer this request, you can enter the following
statement:
>> SELECT FIRST_NAME, LAST_NAME, EMPNUM
+> FROM EMPLOYEE
+> WHERE DEPTNUM = 4000 ;
The SELECT statement specifies the columns, the FROM clause identifies the table,
and the WHERE clause specifies the desired rows.
Figure 2-2 shows the sample query and the list of employees returned by
NonStop SQL/MP.
Figure 2-2. A Simple Query
005
Simple Query
SELECT FNAME, LNAME, EMPNUM
FROM EMPLOYEE
WHERE DEPTNUM = 4000 ;
SELECT FIRST_NAME, LAST_NAME, EMPNUM
FROM EMPLOYEE
WHERE DEPTNUM = 4000 ;
LNAM
E
----
-
-----
-
HOWAR
D
EMPNU
M
RACHEL MCKAY 65
ERIC BROWN 87
...
FIRST_NAME LAST_NAME EMPNUM
---------- --------- ------
Data
In a large table, it is important to use the WHERE clause to limit the amount of
returned data (called the result). If the sample query did not have a WHERE clause,
the result would include every employee name and number in the organization. The
application would then have to manipulate the result to give you only the employees
in department 4000. By providing the means to write highly specific queries,
NonStop SQL/MP relieves the application of extra work and improves application
performance.