SQL WHERE CLAUSE – SQL TUTORIAL | Software Testing Material
SQL WHERE Clause:
The SQL WHERE clause is used to specify a condition while fetching the data from a table. We 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.,
SQL WHERE Clause Syntax:
SELECT column_name_1, column_name_2, .. column_name_n FROM table_name WHERE [condition];
You can specify a condition using comparison or logical operators like >, <, =, LIKE, NOT, etc.
SQL WHERE Clause Example:
SELECT * FROM SCOREBOARD WHERE RUNS>20;
In the below image, you could find total number of records related to first SELECT query are 3Â and total number of records are 2Â related to second SELECT query.
In the second SELECT query, we used WHERE clause with the condition RUNS>20. Note: Runs greater than 20 doesn’t man Runs equal to 20. So in the result we could see just two records.
In the next tutorial, we will see How To Use SELECT DISTINCT Query in SQL
Check out the complete SQL Tutorial by clicking on below link: