Skip to content

Instantly share code, notes, and snippets.

@jqr
Created February 11, 2009 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jqr/62077 to your computer and use it in GitHub Desktop.
Save jqr/62077 to your computer and use it in GitHub Desktop.
-- Demonstration of MySQL bug and a work-around.
-- See http://bugs.mysql.com/bug.php?id=36772
-- It is fixed in MySQL 5.0.74
DROP TABLE `test`;
CREATE TABLE `test` (
`id` INT
);
INSERT INTO `test` VALUES
(123456789),
(123456789);
SET NAMES utf8;
SELECT CAST(id AS CHAR) AS id FROM test GROUP BY id;
-- +------+
-- | id |
-- +------+
-- | 123 |
-- +------+
SELECT CAST(id AS CHAR(20)) AS id FROM test GROUP BY id;
-- +-----------+
-- | id |
-- +-----------+
-- | 123456789 |
-- +-----------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment