How do I make a sql query where fields are the result of a different query?
- by CRP
I have two tables,
the first is like this:
f1 | f2 | f3 | f4
-----------------
data....
the second contains info about the fields of the first:
field | info
------------
f1 a
f2 b
f3 a
etc.
I would like to query the first table selecting the fields with a query on the second. So, for example, I might want to get data for fields where info is equal to "a", thus I would do "select f1, f3 from first_table". How do I do this programmatically? I was thinking about something along the lines of select (select fields from second_table where info='a') from first_table
Thanks
Chris