Take data from a column in a view and insert it into a table

Asked

Viewed 385 times

-1

good evening, I have a problem, I want to take the data of a column in a View I created and put this data in a column of a table, follow the code I used to create the View, I’m already two weeks trying to solve this but there is no way.

create view bag as select name the name, marry when LEFT(name,1) = '*' then 'purse' when RIGHT(name,2) = '**' then 'inclusion'

end as classes

from tbl_user

I am using mysql Workbench 6.3

1 answer

0

I will illustrate based only on the information you put in the question. Come on:

To do what you want, if no information is missing, it is theoretically simple. Here is an example of how to do:

INSERT INTO nome_da_tabela (nome_da_coluna)
SELECT nome_do_campo_da_view FROM nome_da_view;

Note that in the first row is an Insert for the column of that table. In the second row, also simply, there is a select searching for the name of the View column you want to insert into the table.

If you want, you can put some condition in Select in order to filter the result and insert only what interests you in the table.

As I said earlier, it would be interesting for you to put more information, such as the SQL of the tables and views involved in the question.

If there’s any doubt, just say I’ll answer right away.

Big hug.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.