15. Comparison and Logical Operators

As we saw on the previous page, specific records can be found by using a query.

The database can be searched using a comparison operator. This means that you can look for something 'greater than', 'less than', 'before', 'equal to'. The main operators are listed below:

Common Operators
Comparison Operator Means Example
>
Greater than Greater than £10 ; After 01/01/2007
<
Less than Less than £100; Before 01/01/2007
=
Equal to Exactly £25; A date - 12/09/2006
<>
Not equal to Not 12/09/2006 - find all the days there were appointments except for this particular day
>=
Greater than or equal to £10.00 - All values of £10.00 or above (notice this includes the value of £10.00)
<=
Less than or equal to £10.00 - All values of £10.00 or below (notice this includes the value of £10.00)

 

As well as 'comparison operators' such as those shown above, there are also 'logical operators' that you can use in your queries to help you find the records you are looking for:

Logical Operators
Logical Operator Example
AND
Find all the dogs AND all the cats
OR
Find all the dogs who had an appointment on 30/01/2007 OR on 31/01/2007
NOT
Find all the dogs who had an appointment this year but NOT in January

 

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: Database Queries

 

 

 

Copyright © www.teach-ict.com