Home > DeveloperSection > Articles > Conjunctions and Disjunctions in SQL Server

Conjunctions and Disjunctions in SQL Server


Database Database 
Ratings:
0 Comment(s)
 22251  View(s)
Rate this:

Conjunctions and Disjunctions in SQL Server

Conjunctions

Basically the logical conjunction is used to check that two conditions are true, in logical conjunction both conditions must be verified. In a logical conjunction, if either condition is false, the whole statement is false. For instance you have a list of students and you want to study some statistics of your database. You want to get a list of girls, you can filter the students based on the gender and girl’s age should be greater than 20.

I have Employee table and I will use this table to perform operation.

Conjunction and Disjunction in SQL Server

To create a logical conjunction in SQL Server, we use the AND operator to combine two conditions. The formula to follow is:

   Query

select * from Emp where Gender='Female' and Age>20

   Output

Conjunction and Disjunction in SQL Server

Disjunctions

 

A logical disjunction can be performed on one field. Interpreter to find out if the field matches this or that value. In logical disjunction if one condition is true than query will be execute, if first condition is false than OR keyword check next condition is true or not if condition is true query will be execute. For instance I have one condition I want to see that record of person who belong to Allahabad or Varanasi city.

I have StudentDetail table and I will use this table to perform operation.

Conjunction and Disjunction in SQL Server


To create a logical disjunction in SQL Server, we use the OR operator to combine two conditions. The formula to follow is:

Query

select * from StudentDetail where City='Allahabad' or City='Varanasi'

Output

Conjunction and Disjunction in SQL Server

 


Don't want to miss updates? Please click the below button!

Follow MindStick