This is where the differences between the various SQL database vendors becomes apparent. Rather than sticking to the standard, they all have their own variations.
In short, for mySQL servers, ISNULL will replace NULL values with a user specified value.
Say we have a table called orders like this:
--------------------- |order_id |quantity | --------------------- |1 |10 | --------------------- |2 |10 | --------------------- |3 |10 | --------------------- |4 |NULL | ---------------------Now, we will look at how to change NULL in mySQL.
SELECT SUM(IFNULL(quantity,5)) AS result FROM orders; -------- |result| -------- |35 | --------As you can see, we have replaced the NULL values with 5.
No comments:
Post a Comment