|
|
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:
Practice #1: Use BETWEEN operator to display rows based on a range of values. In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. /*
Query result set - 5 rows returned: Practice #2: Use IN operator In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. /*
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 In Firefox (not IE), copy and paste the following SQL to your SQLyog query window. To execute a query, move your cursor anywhere inside the query and then press F9. Note that the SQL needs to end with semi-colon. -- 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:
|
|
Copyright © 2010 GeeksEngine.com. All Rights Reserved. This website is hosted by LunarPages. 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 | Kung Fu Timer | Feedback | Terms of Use | Privacy Policy |