List:General Discussion« Previous MessageNext Message »
From:Jay J Date:October 19 1999 12:05pm
Subject:MID(a_blob, 0, 10) == nuthin ?
View as plain text  
[cross fingers, hope this is an original post]

A very low priority item here (if at all) ..

The manual just says:

SUBSTRING(str,pos,len)
SUBSTRING(str FROM pos FOR len)
MID(str,pos,len)
Returns a substring len characters long from string str, starting at
position pos. The variant form that uses FROM is ANSI SQL92 syntax.

I can understand how the 'pos' is +1 from Perl or C, but it seemed to me
that 'pos = 0' should still return something...?

-Jay J

Versions:
-- mysql  Ver 9.32 Distrib 3.22.23b, for pc-linux-gnu (i486)
-- mysql  Ver 9.32 Distrib 3.22.21, for pc-linux-gnu (i686)

use test; DROP TABLE IF EXISTS my_mid;
CREATE TABLE my_mid ( id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, a_blob
BLOB );
INSERT INTO my_mid (a_blob) VALUES("01234567890");
EXPLAIN my_mid;
SELECT * FROM my_mid;
SELECT id, mid(a_blob, 0, 10) FROM my_mid;          SELECT id, mid(a_blob,
1, 10) FROM my_mid;

+----+--------------------+
| id | mid(a_blob, 0, 10) |
+----+--------------------+
|  1 |                    |
+----+--------------------+
1 row in set (0.00 sec)

+----+--------------------+
| id | mid(a_blob, 1, 10) |
+----+--------------------+
|  1 | 0123456789         |
+----+--------------------+

Thread
MID(a_blob, 0, 10) == nuthin ?Jay J19 Oct