thanq
thanq sir.. thanq very much...
The AND/OR can be used to make a complex or multiple condition for the WHERE clause while selecting, updating or deleting some data.
The AND works as follows
Condition 1 AND condition 2 AND……… condition N
We can use as many conditions as we want with the AND. This condition’s result will only come out to be true if all the conditions are specifies, just like the and truth table
False | False | False |
False | True | False |
False | True | False |
True | True | True |
Similarly we can specify multiple conditions with the OR operator, in OR if one condition is true then the overall condition is accepted to be true no matter how false other conditions are as long as one condition is true
False | False | False |
False | True | True |
False | True | True |
True | True | True |
Now How to use the AND /OR in SQL
Syntax
Consider the following table
Firstname | Lastname | Age | Maritalstatus | Country |
John | Smith | 40 | Married | Usa |
Mathew | Simon | 30 | Married | UK |
Bill | Steve | 20 | Single | Usa |
Amanda | Rogers | 28 | Married | Germany |
Steve | Hills | 30 | Single | france |
Example
Firstname | Lastname | Age | Maritalstatus | Country |
Bill | Steve | 20 | Single | Usa |
Similarly
Firstname | Lastname | Age | Maritalstatus | Country |
John | Smith | 40 | Married | Usa |
Mathew | Simon | 30 | Married | UK |
Bill | Steve | 20 | Single | Usa |
Steve | Hills | 30 | Single | france |