D
D
denislysenko2022-02-13 21:30:41
SQL
denislysenko, 2022-02-13 21:30:41

How can one give a name to the subcolumns that will be displayed using such a .* construction in sql?

There is a nested column, for example, the name of this column is food. The food column contains 2 nested columns: Milk and Oil

To display these sub-columns, you can use the following constructions:
select food.* from table
Either
select food.Milk, food.Oil from table
But, I need the names of these output columns to be food_Milk and food_Oil
This can be implemented like this:

select food.Milk as food_Milk, food.Oil as food_Oil from table


BUT I don't have the option to use it.
select food.Milk as food_Milk, food.Oil as food_Oil from table

because I don't know the name of the sub-columns that will be displayed

And I need to use this construct:
select food.* from table
That is, I can only use a dot with an asterisk, but I don't know how to immediately get these columns with this name:
food_Milk, food_Oil

That is, the name of the columns, should be inherited from the parent column, and then the underscore and the name of the subcolumn itself

. Is it possible to use the .* construction to immediately change their name without knowing how many subcolumns are there?
Is it possible to use the .* construct to change the name of the columns at once?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Myclass, 2022-02-13
@denislysenko

Make the right logic and make it a view, then access it with your select * from your_view

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question