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

10 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
    Replies
    1. Select first field only, remove other fields from the select select statement

      Delete
  4. Thank you Mr. Venkat for this tutorials touching very deeb in a very simple clear way.

    ReplyDelete
  5. Thank you so much such phenomenal job ,i never seen better blog on .net
    like C#,SQL....

    ReplyDelete
  6. Thank you soo much. Your videos and explanations are so amazing that i am able to implement the logics with other rdbms.
    Thank you again.

    ReplyDelete
  7. this video is created in 2012 and still the best tutorial I can find

    ReplyDelete

It would be great if you can help share these free resources