Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
547 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Written by Andrew Gould
In this tutorial
Numbers are perhaps the easiest type of data for which to write criteria, which is why we're using them as a starting point.
You can use a range of different symbols, known as operators, for comparing numbers: the table below shows you the main ones you're likely to use:
Operator | Alternative | What it means |
---|---|---|
= |
| Equal to |
<> | != | Not equal to |
> |
| Greater than |
< |
| Less than |
>= | !< | Greater than or equal to (or not less than) |
<= | !> | Less than or equal to (or not greater than) |
The operator always sits between the two values you are comparing. For example, the query below compares the value of the FilmRunTimeMinutes field with the value 180:
SELECT
FilmName
,FilmRunTimeMinutes
FROM
tblFilm
WHERE
FilmRunTimeMinutes >= 180
The query shows all of the films whose running time is greater than or equal to 180:
The shortest film in this list is 180 minutes long.
You can use the BETWEEN keyword to find numbers that fall between an upper and lower limit. The example below would find all of the films whose running time is between 90 and 100 minutes.
SELECT
FilmName
,FilmRunTimeMinutes
FROM
tblFilm
WHERE
FilmRunTimeMinutes BETWEEN 90 AND 100
A selection of the results from this query are shown below:
You can see from the diagram that films lasting exactly 90 and 100 minutes are included in the results of the query.
You can use the IN keyword to find records that match any values in a list of numbers. The example below looks for films whose running time is exactly 100, 150 or 200 minutes:
SELECT
FilmName
,FilmRunTimeMinutes
FROM
tblFilm
WHERE
FilmRunTimeMinutes IN (100,150,200)
Note that the list of numbers must be enclosed in a set of parentheses. The results of this query are shown in the diagram below:
There aren't any films with a running time of exactly 200 minutes.
Now that you've seen how easy it is to write criteria using numbers it's time to see a few of the quirks of writing criteria involving text.
You can learn more about this topic on the following Wise Owl courses:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.