使用MySQL将二进制转换为十进制 [英] Convert a binary to decimal using MySQL
本文介绍了使用MySQL将二进制转换为十进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在MySQL中构造一个查询,该查询将一堆二进制字段连接起来,然后将结果显示为DECIMAL.
I am trying to construct a query in MySQL that concatenates a bunch of binary fields and then gives me the result as DECIMAL.
例如:
SELECT CONCAT (setting1, setting2, setting3) AS settings;
可以给我:
101
111
110
我想将此值传递给一个函数(转换?强制转换?),该函数将给我相应的DECIMAL值:
I want to pass this value to a function (convert? cast?) that will give me the corresponding DECIMAL value:
5
7
6
我已经尝试了cast()
和convert()
的一些组合,但是还没有破解.
I've already tried a few combinations of cast()
and convert()
but haven't cracked it yet.
推荐答案
CONV(BINARY(CONCAT(setting1,setting2)),2,10)
CONV(BINARY(CONCAT(setting1, setting2)), 2, 10)
这篇关于使用MySQL将二进制转换为十进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文