Support us .Net Basics C# SQL ASP.NET ADO.NET MVC Slides C# Programs Subscribe Buy DVD

Select statement - Part 10

Basic select statement syntax
SELECT Column_List
FROM Table_Name

If you want to select all the columns, you can also use *. For better performance use the column list, instead of using *.
SELECT *
FROM Table_Name







To Select distinct rows use DISTINCT keyword
SELECT DISTINCT Column_List
FROM Table_Name

Example: Select distinct city from tblPerson

Filtering rows with WHERE clause
SELECT Column_List
FROM Table_Name
WHERE Filter_Condition

Example: Select Name, Email from tblPerson where City = 'London'


Note: Text values, should be present in single quotes, but not required for numeric values.

Different operators that can be used in a where clause

4 comments:

  1. how using columnlist would be faster than using * in the select query

    ReplyDelete
    Replies
    1. 1.* reteives all columns even though some of the columns are not requred,it causes performance degadation,time consuming.
      2. In future if we want to change any column alias names while retriving, it is difficult. in that time we must specify thespecified columns.

      Delete
  2. Thank you Mr. Venkat for providing all your tutorials. Now I have a better understanding of SQL.

    ReplyDelete
  3. how to fetch values row wise instead of column wise suppose i have 23 colums i want 1st column's each cell value separately on webpage with single statement

    ReplyDelete

If you like this website, please share with your friends on facebook and Google+ and recommend us on google using the g+1 button on the top right hand corner.