2013-08-05 29 views

回答

3

您可以使用CONV()

CONV('1100', 2, 10) * 1 

Bit-Field Literals

例如

CREATE TABLE Table1 (bit_value BIT(4)); 

INSERT INTO Table1 VALUES (CONV('1100', 2, 10) * 1); 
INSERT INTO Table1 VALUES (b'1101'); 

SELECT bit_value, 
     BIN(bit_value) bin_representation 
    FROM Table1 

輸出:

 
| BIT_VALUE | BIN_REPRESENTATION | 
---------------------------------- 
|  12 |    1100 | 
|  13 |    1101 | 

這裏是SQLFiddle演示