Data Retrieval Facility
To retrieve all the rows in a table, we may use the following statements.
SELECT e_no, e_name, address, basic_salary, job_status
One can select any number of columns in any order from a table to display their values in the specified order.
The simplest operation in SQL is called mapping, which corresponds to the act of finding the values which are associated with another known value in a table. The basic mapping is illustrated by the following query.
Example: To find the names of the employees whose basic salary is greater than 4000.
WHERE basic_salary > 4000
The mapping consists of three keywords, namely, SELECT, FROM AND WHERE; and three parameters namely, the table employees to which the query is directed, the names of the columns of the table whose values will be returned (e_name) and the condition to be satisfied (basic_salary>4000). This format is known as the query block.
A query may specify a complex Boolean condition in the WHERE clause, as illustrated below:
SELECT e-name, address
WHERE (basic_salary >=5000) and (job_status = "Accountant");
The following comparison operators can be used in the Boolean expression under a WHERE clause:
= equal to
# not equal to
> greater than
>= greater than or equal to
< less than
<= less than or equal to