Database Reference
In-Depth Information
This example uses a simple equality test: It checks to see whether a column has
a specified value, and it filters the data accordingly. But
SQL enables you to do
more than just test for equality.
Tip
SQL Versus Application Filtering Data can also be filtered at the application level. To
do this, the SQL SELECT statement retrieves more data than is actually required for
the client application, and the client code loops through the returned data to extract just
the needed rows.
As a rule, this practice is strongly discouraged. Databases are optimized to perform
filtering quickly and efficiently. Making the client application (or development language)
do the database's job dramatically impacts application performance and creates applica-
tions that cannot scale properly. In addition, if data is filtered at the client, the server
has to send unneeded data across the network connections, resulting in a waste of net-
work bandwidth resources.
Caution
WHERE Clause Position When using both ORDER BY and WHERE clauses, make
sure ORDER BY comes after the WHERE ; otherwise, an error will be generated. (See
Chapter 5, “Sorting Retrieved Data,” for more information on using ORDER BY .)
The WHERE Clause Operators
The first WHERE clause we looked at tests for equality—determining whether
a column contains a specific value. MariaDB supports a whole range of condi-
tional operators, some of which are listed in Table 6.1.
Table 6.1 WHERE Clause
Operators
Operator
Description
=
Equality
<>
Nonequality
!=
Nonequality
<
Less than
<=
Less than or equal to
>
Greater than
>=
Greater than or equal to
BETWEEN
Between two specified values
 
 
 
Search WWH ::




Custom Search