Clemens Ladisch wrote:
> it is not possible to generate columns automatically from data values.

"All problems in computer science can be solved by another level of
indirection."  (David Wheeler)

Just use SQL to generate the SQL query:

SELECT 'SELECT units.id AS "unit id"' AS SQL
UNION ALL
SELECT ', cv' || id || '.value AS ' || quote(name) FROM configtypes
UNION ALL
SELECT 'FROM units JOIN unit_types ON units.unit_type_id = unit_types.id'
UNION ALL
SELECT 'LEFT JOIN (unittype_config JOIN configvalues' ||
       ' ON unittype_config.configvalue_id = configvalues.id' ||
       ' AND unittype_config.configtype_id = ' || id || ') AS cv' || id ||
       ' ON unit_types.id = cv' || id || '.unit_id' FROM configtypes


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to