Aaron
Aaron

Reputation: 331

Get column names stored in a different table

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?

Upvotes: 0

Views: 85

Answers (2)

Daniel
Daniel

Reputation: 21

Look into Inner Join
Or Left Join.

Upvotes: 1

ORGPEV
ORGPEV

Reputation: 166

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.

Upvotes: 1

Related Questions