


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The and and or operators are essential tools in sql queries, enabling users to make more precise conditions for fetching data from databases. The and operator sets multiple conditions, requiring all conditions to be met, while the or operator combines conditions, allowing for at least one condition to be satisfied. Examples and explanations of both operators.
Typology: Assignments
1 / 4
This page cannot be seen from the preview
Don't miss anything!



The AND and OR operators are used with the WHERE clause to make more precise conditions for fetching data from database by combining more than one condition together.
AND operator is used to set multiple conditions with the WHERE clause, alongside, SELECT, UPDATE or DELETE SQL queries. Example of AND operator Consider the following Emp table eid name age salary 401 Anu 22 5000 402 Shane 29 8000 403 Rohan 34 12000 404 Scott 44 10000
405 Tiger 35 9000 SELECT * FROM Emp WHERE salary < 10000 AND age > 25 eid name age salary 402 Shane 29 8000 405 Tiger 35 9000 The above query will return records where salary is less than 10000 and age greater than 25. Hope you get the concept here. We have used the AND operator to specify two conditions with WHERE clause.
OR operator is also used to combine multiple conditions with WHERE clause. The only difference between AND and OR is their behaviour. When we use AND to combine two or more than two conditions, records satisfying all the specified conditions will be there in the result.