Skip to content
Activities · Activity 8.8

Q.Compare the output produced by the query in example 8.6 and the following query and differentiate between the OR and AND operators. SELECT *
FROM EMPLOYEE
WHERE Salary > 5000 OR
DeptId= 20;

Odisha ChseTextbookSubjective· 3mImportance★★★★★est
36% · 16/45 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Example 8.6 uses AND, so a row must satisfy both conditions → only 6 employees qualify. The given query uses OR, so a row needs either condition — and since every employee earns more than 5000, all 10 rows come back.

AND = intersection (both true); OR = union (at least one true).

The two queries side by side

Example 8.6 (AND):

SELECT Ename, DeptId
FROM EMPLOYEE
WHERE Salary>=20000 AND Salary<=50000;
EnameDeptId
ShabbirD01
JosephD03
SanyaD02
NachaobiD05
DaribhaD04
TanyaD05

6 rows — with AND, a row is selected only when both conditions are true at the same time (salary at least 20000 and at most 50000). Kritika (60000) fails the second condition; Aaliya (10000), Vergese (15000) and Gurpreet (19000) fail the first — so all four are excluded.

The given query (OR):

SELECT *
FROM EMPLOYEE
WHERE Salary > 5000 OR
      DeptId= 20;

Trace the first condition against Table 8.8: the lowest salary is Aaliya's 10000, so Salary > 5000 is already TRUE for every employee. With OR, one true condition is enough — MySQL never needs the second condition to admit the row. So the result is the whole table:

EmpNoEnameSalaryBonusDeptId
101Aaliya10000234D02
102Kritika60000123D01
103Shabbir45000566D01
104Gurpreet19000565D04
105Joseph34000875D03
106Sanya48000695D02
107Vergese15000NULLD01
108Nachaobi29000NULLD05
109Daribha42000NULLD04
110Tanya50000467D05

10 rows. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.