How to Work with OR Logical Operator in SQL

In this article I am going to explain how to work with AND logical Operator in SQL.
  • 1432

Introduction

In this article I am going to explain how to work with logical operator in SQL. Logical operator in SQL create compound condition. This compound statement in SQL consist of two or more conditions. We use Logical operator with WHERE clause. We use it to find the specific record into result set from table stored in database. It is used to fetch specific row or specific record based on comparison.

There are three type of comparison operator in SQL server.

  • AND Logical Operator
  • OR Logical Operator
  • NOT Logical Operator

OR Logical Operator

OR logical operator return false when both condition are false otherwise it return true value. It means it works when one or both condition are true. 

Example

SELECT * FROM dbo.mcninvoices
WHERE invoicetotal>paymenttotal+creadittotal OR invoicetotal> 1000

Output

Clipboard08.jpg


© 2018 DotNetHeaven. All rights reserved.