Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
An airline desk weighs hand luggage and stores the masses in a table Bags, in kilograms.
BagID Kg
B1 7
B2 3
B3 5
B4 2
B5 9
B6 6Compare these two scripts.
SELECT BagID FROM Bags WHERE Kg < 5;
SELECT BagID FROM Bags WHERE Kg <= 5;How many records does each script output? Explain the difference.
WHERE keeps only the records for which the condition is true. The operators are =, <>, >, <, >= and <=. Text goes in quotes, numbers do not, and a Boolean field is compared with TRUE or FALSE. The field in the condition need not be selected.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Step 1. The masses. , , , , and kilograms.
Step 2. Kg < 5. Only and are less than : B2 and B4. That is records.
Step 3. Kg <= 5. B3 is exactly , so it passes too: B2, B3 and B4. That is records.
Watch out. The two operators differ only for a value equal to the number in the condition.
Answer: records and records. B3, at exactly , passes <= but not <.
Log in to join the discussion.
Loading…