output truncated with ELT when using DISTINCT

Patrick Proniewski <[email protected]>
Newsgroups gmane.comp.db.mysql.bugs
Message-ID <[email protected]>
Hello,

when using both DISTINCT and ELT in a query, I experience problems : 
some strings returned by ELT are truncated.

tested on :
	MySQL 4.0.17 + Linux_thread on FreeBSD 4.8
	MySQL 3.23.38 on Linux
	MySQL 4.0.16 on MacOS X 10.3.2

-- beginning of script --
CREATE TABLE `trunc` (
   `id` int(11) NOT NULL auto_increment,
   `myfield` int(11) NOT NULL default '1',
   PRIMARY KEY  (`id`),
   UNIQUE KEY `id` (`id`)
) TYPE=MyISAM ;

INSERT INTO `trunc` (`id`, `myfield`) VALUES (3, 3);
INSERT INTO `trunc` (`id`, `myfield`) VALUES (4, 3);
INSERT INTO `trunc` (`id`, `myfield`) VALUES (7, 2);
INSERT INTO `trunc` (`id`, `myfield`) VALUES (8, 1);
INSERT INTO `trunc` (`id`, `myfield`) VALUES (16, 1);

SELECT DISTINCT id, 
ELT(myfield,'12345678901234567890','123456','ABCDEFGHIJ') AS outp
FROM trunc
ORDER  BY outp ASC;
-- end of script --

this returns :

+----+------------+
| id | outp       |
+----+------------+
|  7 | 123456     |
|  8 | 1234567890 |
| 16 | 1234567890 |
|  3 | ABCDEFGHIJ |
|  4 | ABCDEFGHIJ |
+----+------------+

and should return :

+----+----------------------+
| id | outp                 |
+----+----------------------+
|  7 | 123456               |
|  8 | 12345678901234567890 |
| 16 | 12345678901234567890 |
|  3 | ABCDEFGHIJ           |
|  4 | ABCDEFGHIJ           |
+----+----------------------+

Is there a clean work around ?

Patrick Proniewski
-- 
je cherche un poste d'admin-sys Mac/UNIX
(ou une jeune et jolie femme riche)
http://patpro.net/cv.php


-- 
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.