Retrieving Records - Using the SELECT Statement Assignment Help

Assignment Help: >> Basics of SQL - Retrieving Records - Using the SELECT Statement

Retrieving Records - Using the SELECT Statement

Retrieving data from the database is the most general SQL operation. Database retrieval is known as a query and is performed by using SELECT statement. A basic SELECT statement holds two clauses or elements:

Select some data (column name(s)) FROM a table or more tables (table name(s)) Retrieval of records can be done in several ways:

•    Selecting all records from a table
•    For all records from a table Retrieving selective columns
•    Selecting records based on conditions
•    Selecting records in a sorted order

Let consider the first case of selecting all the records from the table.

Example

SELECT empno,empname,doj,salary FROM employee;
Here, all the column names are given in the SELECT clause. This can be additionally simplified through giving ‘*’ as follows:

Example

SELECT * FROM employee; this would display:

2389_Retrieving Records - Using the SELECT Statement.png

 

‘*’ indicates all the column names.
Note in the above description, there are no values entered in DOJ and Salary Column for the employee 1001 and 1004. The values in these columns are considered to have NULL values here. Anytime it can be updated using the Update Command.

In the other case, the column names must be specified in the SELECT statement.

Syntax

SELECT col1,col2,.. FROM <tablename>;

Example
SELECT empname,salary FROM employee; The records would be displayed as follows:

1594_Retrieving Records - Using the SELECT Statement 1.png

This statement retrieves the column values of salary and empname.

 

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd