SQL STATEMENT
SELECT Statement
The
SELECT statement is used to select data from a database.
The
result is stored in a result table, called the result-set.
Syntax -
SELECT column_name(s)
FROM table_name |
and
SELECT * FROM table_name
|
Note: SQL is not case sensitive. SELECT is the same as select.
SELECT DISTINCT Statement
In
a table, some of the columns may contain duplicate values. This is not a
problem, however, sometimes you will want to list only the different (distinct)
values in a table.
The
DISTINCT keyword can be used to return only distinct (different) values.
SELECT DISTINCT column_name(s)
FROM table_name |
The WHERE Clause
The WHERE clause is used to extract only those records that fulfill a specified criterion.Syntax -
SELECT column_name(s)
FROM table_name WHERE column_name operator value |
The ORDER BY Keyword
The ORDER BY keyword is used to sort the result-set by a specified column.The ORDER BY keyword sort the records in ascending order by default.
If you want to sort the records in a descending order, you can use the DESC keyword.
Syntax -
SELECT column_name(s)
FROM table_name ORDER BY column_name(s) ASC|DESC |
No comments:
Post a Comment