Friday, November 16

Select Statement- SQL



SELECT

Selecting a Single Column from a table in SQL Server

Syntax:

 Select column_name from table_name 

Example: Consider an existing table T1 having column name C1, C2, C3, C4  respectively.
Now selecting column C2 from table T1 can be written as;

 Select C2 from T1       // Display column C2 from table T1.

Selecting a Multiple Columns from a table in SQL Server

Syntax:

 Select column_name1, column_name2, column_name3 from table_name 

Considering the above example, Selecting columns C1, C3, C4 the query can be written as

Select C1, C3, C4  from T1   // Display columns C1, C3, C4 from table T1.

Selecting All columns from a table in SQL Server

Syntax:

Select * from table_name 

Considering the above example, To Select all columns the query can be written as

Select  from T1     // Display All columns from table T1.