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 46: What does “SELECT 1;” actually do? http://mysql-qotd.casperia.net/archives/345 mysql 5.0/5.1 questions for learning purposes Fri, 06 Aug 2010 16:56:36 +0000 http://wordpress.org/?v=abc hourly 1 By: plogi http://mysql-qotd.casperia.net/archives/345/comment-page-1#comment-52 plogi Fri, 21 May 2010 20:02:58 +0000 http://mysql-qotd.casperia.net/?p=345#comment-52 <b> b c d are correct. It works like selecting a constant from a table with 1 row. <pre> mysql> select 1; +---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec) </pre>   Using the same technique, you can use MySQL as a pocket-calculator: <pre> select 230*12+1; mysql> select 230*12+1; +----------+ | 230*12+1 | +----------+ | 2761 | +----------+ 1 row in set (0.02 sec) </pre> </b>
b c d are correct.
It works like selecting a constant from a table with 1 row.

mysql> select 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

 
Using the same technique, you can use MySQL as a pocket-calculator:

select 230*12+1;

mysql> select 230*12+1;
+----------+
| 230*12+1 |
+----------+
|     2761 |
+----------+
1 row in set (0.02 sec)

]]>