0% found this document useful (0 votes)
11 views2 pages

Practical No 6 Simple Select Statement

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Practical No 6 Simple Select Statement

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical No.

9
Simple Select Statement

Databases store data for later retrieval. Ever wondered how that is achieved? It's
the SELECT SQL command that does the job.

That's what it's all about, retrieving data from the database tables. It's part of the data
manipulation language that is responsible for query the data from the database.

SQL SELECT statement syntax

It is the most frequently used SQL command and has the following general syntax

SELECT [DISTINCT|ALL ] { * | [fieldExpression [AS newName]} FROM tableName [alias] [WHERE condition
][GROUP BY fieldName(s)] [HAVING condition] ORDER BY fieldName(s)

 SELECT is the SQL keyword that lets the database know that you want to retrieve
data.
 [DISTINCT | ALL] are optional keywords that can be used to fine tune the results
returned from the SQL SELECT statement. If nothing is specified then ALL is assumed
as the default.
 {*| [fieldExpression [AS newName]} at least one part must be specified, "*"
selected all the fields from the specified table name, fieldExpression performs some
computations on the specified fields such as adding numbers or putting together
two string fields into one.
 FROM tableName is mandatory and must contain at least one table, multiple tables
must be separated using commas or joined using the JOIN keyword.
 WHERE condition is optional, it can be used to specify criteria in the result set
returned from the query.
 GROUP BY is used to put together records that have the same field values.
 HAVING condition is used to specify criteria when working using the GROUP BY
keyword.
 ORDER BY is used to specify the sort order of the result se

Select operation

The SELECT operation is used for selecting a subset of the tuples according to a
given selection condition. ... It is used as an expression to choose tuples which meet
the selection condition. Select operation selects tuples that satisfy a given predicate.
Project Operation

If the user is interested in selecting the values of a few attributes, rather than
selection all attributes of the Table (Relation), then one should go
for PROJECT Operation.

Where Clause

The SQL WHERE Clause


The WHERE clause is used to filter records.

The WHERE clause is used to extract only those records that fulfill a specified condition.

WHERE Syntax
SELECT column1, column2, ...
FROM table_name
WHERE condition;

WHERE Clause Example


The following SQL statement selects all the customers from the country "Mexico", in the
"Customers" table:

Example
SELECT * FROM Customers
WHERE Country='Mexico';

Try it Yourself »

You might also like