SELECT Command - DotNet and DataBase

Follow us on Facebook

SQL Server Mountain View Mountain View Mountain View

Wednesday, 1 August 2018

SELECT Command

Select is the most commonly used command in SQL. Select command is used to retrieve data from a table or group of statements. We can fetch entire columns in the table or specified columns from the table.

To get all columns from a table
SELECT * FROM <Tablename>; 

To get particular list of columns from a table
SELECT col1,col2,col3 etc FROM <Tablename>;
SELECT * FROM EmployeeInfo;
SELECT ID,EmpName,EmpPhone FROM EmployeeInfo;


Select with alias names:
We can fetch the data from the table by changing the column names run-time. It doesn't impact the original table, but columns would be changed in the result set.

SELECT col1 as <alias name>,col2 as <alias name>,col3 as <alias name> etc FROM <Tablename>;

SELECT ID as EmpployeeID,EmpName as EmpployeeName,EmpPhone  as EmpployeePhone FROM EmployeeInfo;


No comments:

Post a comment


Get Updates On

Discussion updates

Straight Into Your INBOX!

Enter your email address to subscribe to this website and receive notifications of new posts by email.