The Less Than Operator
The < operator finds values smaller than a specified number.
Syntax
sql
1SELECT * FROM table_name
2WHERE column < value;Example: Young Students
Find students younger than 14:
sql
1SELECT * FROM students
2WHERE age < 14;Result
| id | name | age | course |
|---|---|---|---|
| 2 | Bob | 12 | JavaScript |
| 4 | David | 13 | Ruby |
| 5 | Eve | 12 | Python |
More Examples
sql
1-- Marks below 70
2SELECT * FROM students WHERE marks < 70;
3
4-- Students under 13
5SELECT * FROM students WHERE age < 13;
6
7-- Marks below passing (60)
8SELECT name, marks FROM students WHERE marks < 60;With Strings (Alphabetical Order)
Less than works alphabetically with strings:
sql
1-- Names before 'D' alphabetically
2SELECT * FROM students WHERE name < 'D';Returns: Alice, Bob, Carol (names starting with A, B, C)
Key Points
<excludes the boundary value- Works with numbers, dates, and strings
- For dates: earlier dates are "less than"
sql
1-- Orders before a date
2SELECT * FROM orders WHERE order_date < '2024-01-01';