2

Whenever I try:

SELECT column1 FROM table1; 

I get results as comma separated strings (column1 is of type SET):

'result4,result7,result24'
'result2,result15,result36'

etc...

Since mysql SET type is just a 64 BIT string AFAIK - how would I get values as bit string / bit mask?

SELECT function_that_converts_to_bit_string( column1 ) FROM table1;

So result would be:

100100101110000101110
101000110110000101110
100001111100110001110
...

2 Answers 2

1
select bin(cast(column1 as decimal)) from table1;
Sign up to request clarification or add additional context in comments.

2 Comments

I tried it at SQLfiddle and it displayed numbers, although they were in decimal. But I just edited it to display in binary.
YES. this works great. SELECT BIN(column1+0) from table1;. THANKS!
0

What is the datatype and collation for column1?

There is a binary datatype (BINARY itself or BLOB) that you can use to get binary data like so. Also the collation should be set to anything (latin1, utf-8 etc.)-bin The binary collation from whatever collation set you are using, instead of case insensitive (-ci) or case sensitive (-cs) variants.

3 Comments

apologies, I didn't see it in the OP... how about the collation?
utf8-general-ci ... alhough - not sure if that's relevant for set type.
I think it is relevant if you want to get binary data out of it. The query posted by Barmar should work if you change your collation to utf8-bin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.