Introduction:

Here we will explain how to use OR operators in SQL server or what is OR operators in SQL Server Or how to filter record by using OR operators with where clause with example.

Description:

The SQL OR operators are used to filter records based on multiple conditions. It is used with SQL statement WHERE clause. The only one difference between AND and OR is their behavior. When we use AND to filter records two or more than two conditions all conditions should be True. But in case of OR, at least one condition True.

  • AND Syntax
SELECT column1, column2 
FROM table_name
WHERE condition1 OR condition2 

Example:

The Following SQL Statement selects all Records from Student Table.

select s.id,s.Name,s.Mobile,s.address1,s.age,f.amount from Student as s 
inner join Fee as f on s.id=f.StudentId

Result:


OR operators

The following SQL statement selects all students whose amount than 3000 and age greater Than 22.

select s.id,s.Name,s.Mobile,s.address1,s.age,f.amount from Student as s 
inner join Fee as f on s.id=f.StudentId where f.amount  <3000 or s.age >22

Result:


I hope it will help to you.

0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

you may also like