Select


We have inserted data into the table, now the question is how to read this data. Select statement is the answer.  Select is one of the most usefull and powerfull command in SQL and a whole book can be written about it, lets discuss few commonly used features of Select:

Syntax:

SELECT <column_name_1>,
<column_name_2>,
<column_name_N>
FROM <table_name>

[WHERE <select_condition >]
[ORDER BY <order_by_column_name_N>];


Here:
SELECT: Command for selecting the data
<column_name> : table column name to be fetched
FROM : Command for specifying from which table data is required
 <table_name>: Table name from which data is required
WHERE : Optional Command for specfying the filter criteria
Order BY : Optional command to sort the data
<order_by_column_name_N>: column names on which needs to be sorted


For ex:


SELECT   EmpNo,Name , department
FROM Employee
WHERE department = 'sales'
ORDER BY EmpNo ;




1 comment: