Page 270 - Information_Practice_Fliipbook_Class11
P. 270
SET Mgr_Id = 10002
WHERE Dept_No = 1;
On execution of the above SQL statement, DEPARTMENT table appears as shown in Table 9.12.
Table 9.12: Result of UPDATE statement on DEPARTMENT table
+---------+----------------+------------+--------+
| Dept_No | Dept_Name | Location | Mgr_Id |
+---------+----------------+------------+--------+
| 1 | Accounts | Noida | 10002 |
| 2 | Administration | Delhi | 10005 |
| 3 | Home Goods | Mumbai | 10003 |
| 4 | Automobile | Jamshedpur | 10007 |
| 5 | Textile | Mumbai | 10004 |
+---------+----------------+------------+--------+
9.5.10 SELECT statement
SELECT statement is used to retrieve information from database tables. Such statements are also known as SQL
queries. Syntax of a simple SELECT statement is given below:
SELECT attribute_list
FROM table_name;
attribute_list is a comma-separated list of names of the attributes whose value is to be retrieved. For example,
the following SQL statement retrieves department number, name and location for all the departments.
SELECT Dept_No, Dept_Name, Location
FROM DEPARTMENT;
In the above statement, the first line is the SELECT clause that comprises the keyword SELECT and a list of attributes
Dept_No, Dept_Name, Location. The second line is called FROM clause. Execution of the above statement will
produce the output shown in Table 9.13:
Table 9.13: Dept_No, Dept_Name, Location for the DEPARTMENT table
+---------+----------------+------------+
| Dept_No | Dept_Name | Location |
+---------+----------------+------------+
| 1 | Accounts | Noida |
| 2 | Administration | Delhi |
| 3 | Home Goods | Mumbai |
| 4 | Automobile | Jamshedpur |
| 5 | Textile | Mumbai |
+---------+----------------+------------+
Similarly, the following SQL statement yields information about all employees working in the company from the
EMPLOYEE table:
SELECT ID, FName, LName, Gender, Address, City, Pin_Code, DOB, Salary, Dept_No
FROM EMPLOYEE;
When we need to display all attributes in a table, we use the wildcard character * (asterisk) as a placeholder for all the
attributes of the table specified in the FROM clause, as shown below:
SELECT *
FROM EMPLOYEE;
Executing the above statement will produce output shown in Table 9.14.
256 Touchpad Informatics Practices-XI

