Professional Documents
Culture Documents
DBS 09
DBS 09
DBS 09
Database Systems
23 BS Cyber Security – Second Semester
DQL statements are used for performing queries on the data within schema objects.
it is defined as a component of SQL statement that allows getting data (Data Retrieval ) from the
database and imposing order upon it.
This command allows getting the data out of the database to perform operations with it.
When a SELECT is fired against a table or tables the result is compiled into a further temporary table,
which is displayed or perhaps received by the program i.e. a front-end.
SELECT COMMAND
The SELECT Statement in SQL is used to retrieve or fetch data from a database.
We can fetch either the entire table or according to some specified rules.
With the SELECT clause statement, we specify the columns that we want to be
displayed in the query result and, optionally, which column headings we prefer to
see above the result table.
SELECT COMMAND (Cont’d)
Syntax:
SELECT column1,column2 FROM table_name ;
Here, column1 , column2: names of the fields of the table, and table_name: from
where we want to apply query
This query will return all the rows in the table with fields column1 and column2.
SELECT COMMAND (Cont’d)
Suppose we have above table in our database, and we want to retrieve a particular record.
We may use SELECT statement differently to retrieve record and later may apply required operation.
SELECT All RECORDS
Clauses are keywords that are used to filter out values available in the records.
These are used along with DQL and DML queries and pinpoint exact value that the user wants to
retrieve.
WHERE clause is used with the SELECT and DML statements to select, update or delete the
data from a table on the basis of a condition.
WHERE clause selects, deletes, or updates only those rows in which expressions evaluates to
true.
SELECT column_name from table_name
WHERE column_name/expression operator value/expression;
The ORDER BY clause is used to sort the rows that are retrieved from the query.
If you are using ORDER BY clause then it must be the last clause of the query.
You can specify an expression, or an alias, or column position in the sort condition.
ORDER BY Specifies the order in which the retrieved rows are displayed.