Database Reference
In-Depth Information
INSERT INTO Staff (StaffID, Name, DOB,Designation, Department,Address,City,Phone)
VALUES(201,'Sham','5-May-76','Lecturer','EE',' H.No 558 JS Nag','Amritsar','');
INSERT INTO Staff (StaffID, Name, DOB,Designation, Department,Address,City,Phone)
VALUES(234,'Ram','8-Jun-87',' Technician','ME','H.No 513 JS Nag','Amritsar','');
INSERT INTO Staff (StaffID, Name, DOB,Designation, Department,Address,City,Phone)
VALUES(246,'Arun','7-Jan-86','Technician','CSE','H. No 29 JP Nag.',' Jalandhar','');
INSERT INTO Staff (StaffID, Name, DOB,Designation, Department,Address,City,Phone)
VALUES(267,'Sanjeev','7-Jan-88','Lab Astt.','ECE','H. No 65 JP Nag.','Jalandhar','');
7.3.2 Retrieving Data From Tables
SELECT Statement
The SELECT statement is a specialized way to see the data in a database. Thus, a SELECT
statement is also called a query because it quite literally “queries” or asks questions of a
database. There are several uses for the SELECT statement:
Simple query: A SELECT statement can be used to retrieve data from a table or a group
of related tables. All columns or specify columns can be retrieved. Similarly all rows or
specify rows can be retrieved.
Complex query: A SELECT statement can be embedded within another SELECT state-
ment. You can write a query within a query.
Create a view or table: A SELECT statement can be used to create a view or a new table. A
view is a stored query that is executed whenever another SELECT statement retrieves data
from the view by using the view in a query. Views are very useful to enforce security by
limiting the columns or rows that particular users are allowed to see.
Insert, update, or delete data: A SELECT statement can be used within the INSERT,
UPDATE, or DELETE statements to make these more flexibility commands.
Retrieving Individual Columns
The required column name is specified right after the SELECT keyword, and the
FROM keyword tells the name of the table from which to get the data.
Syntax:
SELECT columnname FROM tablename;
Example: Show data StaffID column from staff table
SELECT StaffID FROM Staff;
Retrieving Multiple Columns
Search WWH ::




Custom Search