Warning: Creating default object from empty value in /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 4991
Warning: Creating default object from empty value in /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 4993
Warning: Cannot modify header information - headers already sent by (output started at /www/htdocs/v030397/mysql-qotd/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php:4991) in /www/htdocs/v030397/mysql-qotd/wp-includes/feed-rss2-comments.php on line 8 Comments on: Question 22: What will the following query return?
http://mysql-qotd.casperia.net/archives/203
mysql 5.0/5.1 questions for learning purposesFri, 06 Aug 2010 16:56:36 +0000http://wordpress.org/?v=abchourly1By: urs
http://mysql-qotd.casperia.net/archives/203/comment-page-1#comment-28
ursThu, 18 Feb 2010 18:20:12 +0000http://mysql-qotd.casperia.net/?p=203#comment-28<b>
Answer:
c
The MIN/MAX values for an empty table are undefined and therefore NULL. I've seen statistics and reporting software abort because of empty tables ;-) You can use <code>COALESCE()</code> or <code>IFNULL()</code> to catch those <code>NULL</code>-values.
<code>mysql> select min(n),max(n) from mintst;
+--------+--------+
| min(n) | max(n) |
+--------+--------+
| NULL | NULL |
+--------+--------+
1 row in set (0.00 sec)</code>
</b>
Answer:
c
The MIN/MAX values for an empty table are undefined and therefore NULL. I’ve seen statistics and reporting software abort because of empty tables ;-) You can use COALESCE() or IFNULL() to catch those NULL-values.
mysql> select min(n),max(n) from mintst;
+--------+--------+
| min(n) | max(n) |
+--------+--------+
| NULL | NULL |
+--------+--------+
1 row in set (0.00 sec)