Sunday, 5 August 2007

Explain SELECT statement in SQL Server.

The SELECT statement is used to select data from a table, basically the SELECT statement will have three clauses,

SELECT - specifies the table columns retrieved
FROM - specifies the tables to be accessed
WHERE - specifies which rows in the FROM tables to use

The WHERE clause is optional and commonly called as Condition, if it is not used all the table rows will get displayed.

Ex :
Select EmployeeName, EmployeeID from Employees;

This Query will list the Employee Name and Employee ID column from table “Employees”.

Select * from Employees;

This Query will list all the columns in the entire table “Employees”.

Select Distinct Department from Employees;

This Query select only the different values from column named “Department” in “Employees” table.

Select EmployeeName, EmployeeID from Employees where City is NULL

This Query selects the list of Employees who have not specified their city name in the table, if you want to list the Employees who specified the city in table use “where city is NOT NULL”.

Labels:


Bookmark this Blog in your Favorites

1 Comments:

Blogger suni said...

nice info shared
http://www.train4job.com/

4 August 2011 at 09:32  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home