|
Custom Search
| |
|
Using Comparison Operators, Part II Comparison operators are used in WHERE clause that compare one expression to another. Read Prerequisites for this tutorial and practices if you haven't done so. Part II of this tutorial covers the following comparison operators:
Most of the queries in the tutorials need Northwind MySQL database, you can download the database script on this page. Practice #1: Use BETWEEN operator to display rows based on a range of values. /*
Query result set - 5 rows returned: Practice #2: Use IN operator /*
Query result set - 8 rows returned: Practice #3: Use LIKE operator See Using LIKE Operator section for detailed information. Practice #4: Use IS NULL operator -- Find who is the top employee in the reporting structure. IS NULL operator tests if a value is NULL. A NULL value does not mean zero or empty string. Zero is an integer data type. Empty string is a zero length string data type. NULL value means the value is undefined, unknown, or unassigned. Therefore, we can't use equal sign (=) to check if a value is equal to or not equal to NULL. We can use IS NULL operator or use NULL-safe operator. The query above displays the employee who does not report to anyone.
Query result set - 1 row returned: Other tutorials in this category 1. The Basic SELECT Statement |
Copyright © 2024 GeeksEngine.com. All Rights Reserved. This website is hosted by HostGator. No portion may be reproduced without my written permission. Software and hardware names mentioned on this site are registered trademarks of their respective companies. Should any right be infringed, it is totally unintentional. Drop me an email and I will promptly and gladly rectify it. |
Home | Feedback | Terms of Use | Privacy Policy |