On Mon, Oct 13, 2014 at 7:52 AM, Paul Sanderson < sandersonforens...@gmail.com> wrote:
> I have a table with an integer value which is a bitmask. one or more of the > bits can be set and each bit has a corresponding meaning. > > so using the windows file attribute as an example we have > > 0c01 readonly > 0x02 hidden > 0x04 system > 0x10 directory > 0x20 archive > > none, any or all could be set > > I'd like to create a query which would take an attribute, say 0x07 and spit > out "system, hidden, readonly" > WITH RECURSIVE all_bit_patterns(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM all_bit_patterns WHERE x<0x1f) SELECT x, (SELECT group_concat(name) FROM (SELECT 0x01 AS id, 'readonly' AS name UNION ALL SELECT 0x02, 'hidden' UNION ALL SELECT 0x04, 'system' UNION ALL SELECT 0x08, 'directory' UNION ALL SELECT 0x10, 'archive') WHERE (x&id)!=0) FROM all_bit_patterns; -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users