If by Decimal you mesn HEXIDECIMAL you can use CONV where the 1st arg is the HEX value, 2nd arg is From Base and 3rd arg is To Base.
You will have to suround the aliases with "`'s" if you really want the names to be numeric. mysql> select MID(CONV('A5',16,2),1,1) AS `7`, -> MID(CONV('A5',16,2),2,1) AS `6`, -> MID(CONV('A5',16,2),3,1) AS `5`, -> MID(CONV('A5',16,2),4,1) AS `4`, -> MID(CONV('A5',16,2),5,1) AS `3`, -> MID(CONV('A5',16,2),6,1) AS `2`, -> MID(CONV('A5',16,2),7,1) AS `1`, -> MID(CONV('A5',16,2),8,1) AS `0` ; +---+---+---+---+---+---+---+---+ | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +---+---+---+---+---+---+---+---+ | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | +---+---+---+---+---+---+---+---+ 1 row in set (0.00 sec) -----Original Message----- From: Ed Reed [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 10, 2006 12:16 PM To: mysql@lists.mysql.com Subject: Converting decimal to binary Can anyone tell me if it's possible, in 4.1.11, to convert a decimal number to binary and have the result be returned as a separate field for each bit? For example, what I'd like to do is, Select ConvertToBin(245); And have a result that looked like this +---+---+---+---+---+---+---+---+ | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +---+---+---+---+---+---+---+---+ | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | +---+---+---+---+---+---+---+---+ - Thanks -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]