The MS SQL Server WHERE proviso is utilized to determine a condition while getting the information from single table or getting together with numerous tables.
On the off chance that the given condition is fulfilled, really at that time it restores a particular incentive from the table. You should utilize WHERE statement to channel the records and get just essential records.
The WHERE condition isn't just utilized in SELECT explanation, however it is likewise utilized in UPDATE, DELETE articulation, and so forth, which we would look at in ensuing parts.
Syntax
Following is the fundamental punctuation of SELECT explanation with WHERE provision −
SELECT column1, column2, columnN
FROM table_name
WHERE [condition]
You can indicate a condition utilizing examination or coherent administrators like >, <, =, LIKE, NOT, and so on The accompanying model will make this idea understood.
Example
Consider the CUSTOMERS table having the accompanying records −
ID NAME AGE ADDRESS SALARY
1 Ramesh 32 Ahmedabad 2000.00
2 Khilan 25 Delhi 1500.00
3 kaushik 23 Kota 2000.00
4 Chaitali 25 Mumbai 6500.00
5 Hardik 27 Bhopal 8500.00
6 Komal 22 MP 4500.00
7 Muffy 24 Indore 10000.00
Following order is a model which would get ID, Name and Salary fields from the CUSTOMERS table where compensation is more noteworthy than 2000.
SELECT ID, NAME, SALARY
FROM CUSTOMERS
WHERE SALARY > 2000;
The above order will create the accompanying yield.
ID NAME SALARY
4 Chaitali 6500.00
5 Hardik 8500.00
6 Komal 4500.00
7 Muffy 10000.00
Following order is a model, which would bring ID, Name and Salary fields from the CUSTOMERS table for a client with the name 'Hardik'. Note that all the strings ought to be given inside single statements ('') while numeric qualities ought to be given with no statement as in the above model −
SELECT ID, NAME, SALARY
FROM CUSTOMERS
WHERE NAME = 'Hardik';
The above order will create the accompanying yield.
ID NAME SALARY
5 Hardik 8500.00