Bug #10445 ?
Submitted: 8 May 2005 7:33 Modified: 8 May 2005 16:29
Reporter: Kiran K Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.1 OS:Windows (Windows XP)
Assigned to: CPU Architecture:Any

[8 May 2005 7:33] Kiran K
Description:
I am using MySQL Server 4.1 , MySQL Command Line Client.
I have created a table with following syntax.

create table dbiroute ( Rname varchar(15) );

When i am executing the following:

select 44441123 from dbiroute;

i am getting the following result

+----------+
| 44441123 |
+----------+
| 44441123 |
| 44441123 |
+----------+
2 rows in set (0.01 sec)

Is it correct ?, I know this is not a big critical issue. But still i wounld like to know what is behind the output.

How to repeat:
mysql> create table test ( t varchar(20) );
Query OK, 0 rows affected (0.33 sec)

mysql> select 123 from test;
Empty set (0.01 sec)

mysql> insert into test values ( 'hai' );
Query OK, 1 row affected (0.08 sec)

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

mysql>
[8 May 2005 16:29] Hartmut Holzgraefe
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

Whenever you are selecting data from a table without a where condition
you get as many result rows as there are rows in the table, even if
you are only asking for constant values and not for any table fields
at all.

If you just want to get a constant value or a function result back
you can just use a select query without a from clause, eg.:

  SELECT 12345;

or

  SELECT VERSION();