I have a table like this:
// mytable
+---------+-------------+
| id | bitmap |
+---------+-------------+
| int(11) | BIT(10) |
+---------+-------------+
| 1 | 01111111000 |
| 2 | 01111111111 |
| 3 | 00000000001 |
+---------+-------------+
And these are some examples of both current and expected output:
Example1:
SELECT bitmap INTO @var FROM mytable WHERE id = 1;
SELECT @var;
/* Current output: 1016
Expected output: 01111111000
*/
Example2:
SELECT bitmap INTO @var FROM mytable WHERE id = 2;
SELECT @var;
/* Current output: 1023
Expected output: 01111111111
*/
Example3:
SELECT bitmap INTO @var FROM mytable WHERE id = 3;
SELECT @var;
/* Current output: 1
Expected output: 00000000001
*/
Well how can I do that? As you see, I'm trying to assign the original bit value of that column to that variable (but seems there is a conversion, how can I avoid that?). I really don't know why @var
isn't contain a binary value.