Using MySQL in and between Clauses
In and between are two functions MySQL offers that aren’t something I use on a daily basis but they are incredibly useful from time to time for specific operations. The in() function can be IN() or NOT IN() and the same is applicable for BETWEEN or NOT BETWEEN.
Here some example queries of this functionality in use:
<?PHP //EXAMPLE USING MYSQL IN $sql = "SELECT * FROM table WHERE zip IN ('99863','98563',98542')"; //EXAMPLE USING MYSQL NOT IN $sql = "SELECT * FROM table WHERE zip NOT IN ('99863','98563',98542')"; //EXAMPLE USING MYSQL BETWEEN $sql = "SELECT * FROM table WHERE age BETWEEN 35 and 45"; //EXAMPLE USING MYSQL NOT BETWEEN $sql = "SELECT * FROM table WHERE age NOT BETWEEN 21 and 30"; ?>
No related posts.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.


Hi,
your examples are very usefull and easy to understand.
Great job, thx