-4

I have two tables. First table have column called column_name which contains values columns names of the second table like ( column1 , column2 , etc). I need to select columns from the second table depending on the result of query column_name from the first table .

I need help solving this issue but I cant develop it:

sebenalern
  • 2,515
  • 3
  • 26
  • 36
  • 1
    Add some sample table data and the expected result. – jarlh May 30 '16 at 09:12
  • 1
    Are you using MySQL or Oracle? (Don't tag products not involved.) – jarlh May 30 '16 at 09:12
  • Please considered that questions like "how to do it?" are considered off-topic here; you should add something about what you tried so far, the problems you are having, ... – Aleksej May 30 '16 at 09:14
  • Possible duplicate of [MySql select dynamic row values as column names](http://stackoverflow.com/questions/25410946/mysql-select-dynamic-row-values-as-column-names) – Lajos Arpad May 30 '16 at 09:16
  • image added with what i need in details please help – user5572082 May 30 '16 at 13:11

1 Answers1

0

If You work with Oracle, i suggest You to use listagg function (http://www.oracle-developer.net/display.php?id=515)

And Query will be like:

Select column_name from all_tab_columns where table_name = name_of_your_table2 and column_name in (select listagg...)

if I understand correctly.

Michał M
  • 618
  • 5
  • 13