Skip to content

Instantly share code, notes, and snippets.

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 huobazi/325354732eacae7d43d2ccadba66c30e to your computer and use it in GitHub Desktop.
Save huobazi/325354732eacae7d43d2ccadba66c30e to your computer and use it in GitHub Desktop.
dirty-magic-on-how-to-convert-bigint-to-int-in-mysql
/*
ref: https://stackoverflow.com/questions/11595217/convert-bigint-unsigned-to-int#11595484
*/
/*
CREATE FUNCTION long2int (n BIGINT) RETURNS INT(11) RETURN n;
*/
SET @a:= CAST('111' AS SIGNED );
DROP TEMPORARY TABLE IF EXISTS foo;
CREATE TEMPORARY TABLE foo SELECT long2int(@a); -- dirty magic
DESC foo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment