Actually CONV converts from any base to any base so if it is base 10 then just replace the 16's with 10's.
Too much time looking at dump's. -----Original Message----- From: Bill Dodson [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 10, 2006 3:09 PM To: Gordon Bruce Cc: Ed Reed; mysql@lists.mysql.com Subject: [SPAM] - Re: Converting decimal to binary - Bayesian Filter detected spam If you really do mean decimal (base 10) you could use Gordon's solution like this: SELECT MID(CONV(HEX(245),16,2),1,1) AS `7`, MID(CONV(HEX(245),16,2),2,1) AS `6`, MID(CONV(HEX(245),16,2),3,1) AS `5`, MID(CONV(HEX(245),16,2),4,1) AS `4`, MID(CONV(HEX(245),16,2),5,1) AS `3`, MID(CONV(HEX(245),16,2),6,1) AS `2`, MID(CONV(HEX(245),16,2),7,1) AS `1`, MID(CONV(HEX(245),16,2),8,1) AS `0` ; Results: +---+---+---+---+---+---+---+---+ | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +---+---+---+---+---+---+---+---+ | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | +---+---+---+---+---+---+---+---+ Hope this helps. Gordon Bruce wrote: >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 > > > > > -- Bill Dodson Parkline, Inc. http://www.parkline.com phone: 304-586-2113 x149 fax: 304-586-3842 email: [EMAIL PROTECTED] Email Disclaimer The information in any email is confidential and may be legally privileged. It is intended solely for the addressee. Access to the email message by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, or distribution of the message, or any action or omission taken by you in reliance on it, is prohibited and may be unlawful. If you have received an email message in error, please notify the sender immediately by email, facsimile or telephone and return and/or destroy the original message. Thank you. -- 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]