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
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
how using columnlist would be faster than using * in the select query
ReplyDelete1.* reteives all columns even though some of the columns are not requred,it causes performance degadation,time consuming.
Delete2. In future if we want to change any column alias names while retriving, it is difficult. in that time we must specify thespecified columns.
Thank you Mr. Venkat for providing all your tutorials. Now I have a better understanding of SQL.
ReplyDeletehow 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
ReplyDeleteSelect first field only, remove other fields from the select select statement
DeleteThank you Mr. Venkat for this tutorials touching very deeb in a very simple clear way.
ReplyDeleteThank you so much such phenomenal job ,i never seen better blog on .net
ReplyDeletelike C#,SQL....
Thank you soo much. Your videos and explanations are so amazing that i am able to implement the logics with other rdbms.
ReplyDeleteThank you again.
this video is created in 2012 and still the best tutorial I can find
ReplyDeleteWatching in 2022 and still the best
ReplyDelete