Conjunctions and Disjunctions in SQL Server
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.
To create a logical conjunction in SQL Server, we use the AND operator to combine two conditions. The formula to follow is:
select * from Emp where Gender='Female' and Age>20
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.
To create a logical disjunction in SQL Server, we use the OR operator to combine two conditions. The formula to follow is:
select * from StudentDetail where City='Allahabad' or City='Varanasi'