lundi 23 novembre 2015

Sqlite3 - Select column with column name specified in another table

I m struggling with a Sqlite3 problem. I have a table which contains data split up in different parameters. This data represents messages which can have different format.

This table has the fields :

ID | FORMAT | param1 | param2 ... param30

I have an other table which describe each parameter for the different messages format :

FORMAT | name | paramID

Entries in this table would look like :

10 | sequence number | param1

10 | value1 | param2

20 | time | param1

and so on...

I would like to know if it is possible to perform a select on the first table of the parameters that are defined in the second tables ? The query would need to be the same for every format (I need to extract all messages in a loop to send them).

For example it would return:

10 | param1 | param2 (if the format is 10)

and

20 | param1 (if the format is 20)

I would concatenate the parameters together so I would always have two columns in my resulting table.

It looks like a join but not in column name only but in column name for table 1 and value for table 2.

One solution would be to select all the parameters every time and process the data after however I would like to know if there is an other solution using sqlite.

I m still in the developement phase so I can change the format of my tables. The first table needs to have the messages split up in different parameters and I need to be able to identify these parameters with an other table.

Thanks in advance for your help !

Aucun commentaire:

Enregistrer un commentaire