In SQL, there are also these four operators
- Less than
- Greater than
- Less than or equal to
- Greater than or equal to
If you remember math as a kid (well probably a teenager), it’s the same concept as you see in math. Let’s say we want to find the students who scored at or above 90% in our sample database:
SELECT StudentID FROM Stats.Scores WHERE Score >= '90'
You could also pick out the students who didn’t do so well by running something like this:
SELECT * FROM Stats.Scores WHERE Score < '60'
This can only be used in certain data field types (mainly numbers) – but you can also do it against words as well (provided the words are somewhat similar). For example:
SELECT StudentID FROM Stats.Scores WHERE StudentID > Student C
Gives us a result of:
1 2 3 4 5 6 7 8 9 10 11 12 13
Student E Student D Student H Student I Student F Student G Student E Student D Student H Student I Student F Student G Student J
It’s also handy against dates and identity fields. These particular operators are somewhat basic but it’s good to have a good understanding of them. So play around with them a little bit and get comfortable with them.