Retrieve data: – Retrieving data from existing table is one of the most important feature of data query language. The select statement is used to get data from the single table as well as from the multiple tables. This statement retrieves all data or part of data from existing table(S). if user want to retrieve all field from existing table, use an asterisk sign. The select statement can be use with or without condition. If it is use without any condition, all records are retrieve and if it is use with some condition, only part of record are retrieved. Syntax of the select statement is –
Select <*/Field Names> from <Table Name> (Where <Test Expression>);
Some examples of select statement are as fallows –
Select * from employee;
Here employee is a name of existing table and * sign indicate for values of all columns. When above statement is executed, all column values of all records are displayed on screen of table employee.
Select ename,ecode from employee;
The above statement will display only column values of ename and ecode from table employee.
Select * from employee where grosspay > 5000;
In case of above example, only those rows are displayed with there all column values which grosspay column is greater than 5000.
Select ename,ecode from employee where cname=’Kolkata’
In case of the above example, only ename and ecode column are displayed from table employee which cname=’Kolkate’