Database Reference
In-Depth Information
We have already seen an example of testing for equality. Here's one more:
▼
Input
SELECT prod_name, prod_price
FROM products
WHERE prod_name = 'fuses';
▼
Output
+-----------+------------+
| prod_name | prod_price |
+-----------+------------+
| Fuses | 3.42 |
+-----------+------------+
▼
Analysis
Checking for
WHERE prod_name = 'fuses'
returned a single row with a
value of
Fuses
. By default, MariaDB is not case sensitive when performing
matches, and so
fuses
and
Fuses
match.
Now look at a few examples to demonstrate the use of other operators.
This first example lists all products that cost less than
10
:
▼
Input
SELECT prod_name, prod_price
FROM products
WHERE prod_price < 10;
▼
Output
+---------------+------------+
| prod_name | prod_price |
+---------------+------------+
| .5 ton anvil | 5.99 |
| 1 ton anvil | 9.99 |
| Carrots | 2.50 |
| Fuses | 3.42 |
| Oil can | 8.99 |
| Sling | 4.49 |
| TNT (1 stick) | 2.50 |
+---------------+------------+
This next statement retrieves all products costing
10
or less (resulting in two
additional matches):