Home > Enterprise >  Get column names stored in a different table
Get column names stored in a different table

Time:10-16

I have a table that has just a code for the individual column name like "A1G", "Z8H" etc. enter image description here

This table is a really huge table. Therefore it would not help to manually add the alias name in the SELECT Statement like.

The description for each column code is stored in a different table: enter image description here

Now I would like to SELECT * from the first table but with the right column header name. This is stored in the second table within the filters Schema = 'ABC' and Table = 'A'. That would be desired output:

enter image description here

How would you do that in SQL? How can I change the column name?

CodePudding user response:

Look into Inner Join: https://www.w3schools.com/sql/sql_ref_inner_join.asp Or Left Join: https://www.w3schools.com/sql/sql_join_left.asp

CodePudding user response:

You would be better off just creating a view with all the columns aliased to your preferred names. Once that's done you can select from the view and get the data back with the headings you want.

  • Related