Anyone have any SQL-fu (can be MySQL-specific) that will give me the indexes of set bits in an int, without using a procedure? How about with a procedure?
For example, given:
create table example (val int);
insert into example values (1), (2), (3), (4), (256);
I can see the set bits:
select conv(val, 10, 2) from example;
+------------------+
| conv(val, 10, 2) |
+------------------+
| 1 |
| 10 |
| 11 |
| 100 |
| 100000000 |
+------------------+
I need magic that will give me:
+------------------+
| (something) |
+------------------+
| 1 |
| 2 |
| 1,2 |
| 3 |
| 9 |
+------------------+
.. happy to get 0-based, too.