Get alias name dynamically in Postgresql
I have one table named tblalias.which is having two columns cid, description
cid description
1 Employee
2 Join Date
3 Retire Date
Like this three record is present
Now I have another table tblemployee
. I want to write a query for tblemployee
to get record but alias name for that query I want should come from tblalias
select nama as Employee,
joindate as "Join Date",
retire开发者_JS百科date as "Retire Date"
from tblemployee
If I change value is tblalias
table to my select query should return new value as alias is it possible if yes how please help me
The only way to do this is with dynamic SQL. First fetch the alias names then build the final SQL and execute it.
There is no way doing this with a single "hardcoded" statement.
If you want spaces in names you should quote them. (spaces in names is generally a bad Idea, but that's another matter)
精彩评论