Changes

Jump to: navigation, search

Advanced MySQL Data Filtering - AND, OR, NOT and IN

26 bytes added, 02:53, 13 October 2007
Filtering using the OR Operator
In the previous chapter of [[MySQL Essentials]] we looked at some basic filtering of retrieved data using the ''WHERE'' clause of the ''SELECT'' statement. While the basics covered simple filtering techniques, there are often situations where more sophisticated filtering is required. To address this need, the WHERE clause allows multiple conditions to be defined in a single SELECT statement using ''AND'', ''OR'' ''IN'' and ''NOT'' operators.
== Filtering using Data Using the OR Operator ==
In the previous chapter we looked at filtering the data retrieved using a ''SELECT'' statement based on single criteria. For example, we retrieved all the products in a table where the product price was below a particular threshold. Imagine, however, if you wanted to retrieve all the rows from a table where the product matched either one value or another. This can be achieved using the ''WHERE'' clause in combination with the ''OR'' operator. Say, for example that we need to list all products in our sample database that cost less than $100 or greater than $200. The SQL statement to achieve this would read as follows:
5 rows in set (0.00 sec)
</pre>
 
== Headline text ==
== Filtering Using the AND Operator ==

Navigation menu