Conjunctions and Disjunctions in SQL Server
The Conjunctions
Basically the logical conjunction is used to check that two conditions are true, in logical conjunction both conditions must be verified.
In 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 for 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 an Employee table and I will use this table to perform an operation.
To create 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
Disjunctions
A logical disjunction can be performed in one field. Interpreter to find out if the field matches this or that value.
In logical disjunction, if one condition is true than the query will be executed, if the first condition is false then the OR keyword check next condition is true or not if
the condition is true query will be executed. For instance, I have one condition I want to see that record of the person who belongs to Allahabad or Varanasi city.
I have a StudentDetail table and I will use this table to perform the operation.
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
Anonymous User
04-Apr-2019Thanks for the informative post.