Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a problem I can not solve and found no solutions on the web. I have two database tables (in postgresql).

Table_A is the real dataset:

date; var_1; var_2; var_3; var_4; var_5; ....; var_100
03-10-14; A; 15; B; 10; 7; ...; TT
04-10-14; U; 67; G; 9; 99; ...; LLK
etc 
etc

Table_B is the "metadata":

var; long_name; type; use;
date; Date of transaction; DATE; yes
var_1; Type of customer; ATTRIBUTE; yes
var_2; Age; NUMBER; yes
etc 
ect

So each column of table_A has the metadata definied in a row of table_B

Now the problem:

I want to write a query in php that returns the data of table_A with ONLY the column defined as DATE in table_B and each one of the columns defined as ATTRIBUTE en table_B.

Obviously I want to perform this dynamically (I do not want to write the query when the tables change...)

I tried many approaches I succeeded with the DATE column and ONE ATTRIBUTE, but not all.

Any ideas? THANKS in advance

share|improve this question
    
Please share what you have tried. –  Jay Blanchard yesterday
    
Is this your table design? This is not a typical use of relational DB. Metadata are the column definitions you can query, and comments. –  Str. yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.