On 26 May 2014, at 3:50pm, Igor Tandetnik <[email protected]> wrote:

> You can't do that. SQL allows you to manipulate values, but not names. All 
> table and column names are set in stone when the query is prepared and the 
> execution plan is determined.

And the fact that you're even trying to do it may be a sign that your database 
needs refactoring.  If column names are variable then they should be column 
values.  So a table like

ID      COL1    COL2    COL3    COL4
1       876     67      68      54
2       54      875     46      45
3       57      445     67      4

should actually be

ID      PROP    VALUE
1       1       876
1       2       67
1       3       68
1       4       54
2       1       54
...

with a primary key of (ID, PROP).

That means you can select anything you want and you don't have to try to treat 
a fixed thing as variable.

Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to