Where Clause with Logical Operators

To fetch records of  Employee with ages equal to 24. 

Query:

SELECT * FROM Emp1 WHERE Age=24;

Output:

 

To fetch the EmpID, Name and Country of Employees with Age greater than 21. 

Query:

SELECT EmpID, Name, Country FROM Emp1 WHERE Age > 21;

Output:

 

SQL | WHERE Clause

WHERE keyword is used for fetching filtered data in a result set. It is used to fetch data according to particular criteria. WHERE keyword can also be used to filter data by matching patterns.

Syntax:

SELECT column1,column2 FROM table_name WHERE column_name operator value;

Parameter Explanation:

  1. column1,column2: fields in the table
  2. table_name: name of table
  3. column_name: name of field used for filtering the data
  4. operator: operation to be considered for filtering
  5. value: exact value or pattern to get related data in result 

Similar Reads

List of Operators that Can be Used with WHERE Clause

Operator Description > Greater Than >= Greater than or Equal to < Less Than <= Less than or Equal to = Equal to <> Not Equal to BETWEEN In an inclusive Range LIKE Search for a pattern IN To specify multiple possible values for a column...

Where Clause with Logical Operators

To fetch records of  Employee with ages equal to 24....

Where Clause with BETWEEN Operator

It is used to fetch filtered data in a given range inclusive of two values....

Where Clause with LIKE Operator

It is used to fetch filtered data by searching for a particular pattern in the where clause....

Where Clause with IN Operator

It is used to fetch the filtered data same as fetched by ‘=’ operator just the difference is that here we can specify multiple values for which we can get the result set....