Where Clause in Sql Server Management Studio

The SQL WHERE clause is used to specify a condition while fetching the data from single table or joining with multiple tables.
If the given condition is satisfied, then only it returns specific value from the table. You would use WHERE clause to filter the records and fetching only necessary records.
The WHERE clause is not only used in SELECT statement, but it is also used in UPDATE, DELETE statement, etc., which we would examine in subsequent chapters.
Syntax:
The basic syntax of SELECT statement with WHERE clause is as follows:

SELECT COLUMN_NAME1, COLUMN_NAME2, .., Column_NameN FROM TABLE_NAME Where [Condition]


You can specify a condition using comparison or logical operators like >, <, =, LIKE, NOT, etc. Below examples would make this concept clear.
Example:
Consider the TechnoCratEmployee table having the following records:



SELECT * From TechnoCratEmployee



























Following is an example which would fetch ID, Name and Salary fields from the CUSTOMERS table where salary is greater than or Equal to 5000:


SELECT Id, Name, salary, Email from TechnoCratEmployee Where Salary >=5000



























Here we got the result whose salary is greater than or equal to 5000.



THANKS TO READ HOPE YOU GAINED FROM HERE


No comments:

Post a Comment