Pergunta

I have a select query (using a prepared statement) which returns a Resultset. For example the query can be :

 SELECT * FROM TABLE;

and I want the result of this query to insert in another table, the select query is stored at database and will be usually a join query, so i don't know exactly the columns of the table, how its possible for each row of the Resultset to make an insert row in the form:

INSERT INTO TABLE VALUES ('THE VALUES FROM THE SELECTED ROW IN THE RESULTSET');
Foi útil?

Solução

you can do both in one state ment:

insert into TableB (Col1, col2, col3, col4, etc..)
select Col1, col2, col3, col4, etc.. from Table A where Col5='condition'
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top