You can translate the question and the replies:

INSERT INTO with SELECT

Hi Team, Could you please confirm the below limitation of VQL syntax. Working - INSERT INTO view2 SELECT col1 FROM view1; Working - INSERT INTO view2 (col1) VALUES ("abc"); Not working - INSERT INTO view2 (col1) SELECT col1 FROM view1; Not working - INSERT INTO view2 (col1) VALUES SELECT col1 FROM view1; Please suggest alternative if only certain column value to be passed to insert statement with select query. Thanks, Sripathi
user
13-10-2021 09:41:35 -0400
code

3 Answers

Hi , INSERT INTO view2 (col1) VALUES SELECT col1 FROM view1; This is an incorrect syntax. VALUES and SELECT clause do not work together Also in INSERT INTO .... SELECT FROM Synatax - You dont need to specify Column Name in Select clause. Instead Column Name in Select should match with Column in Targer table.
user
14-10-2021 05:13:10 -0400
Thanks for the confirmation. I am aware #4 is wrong syntax and expected to fail. However #3 is [standard](https://www.w3schools.com/sql/sql_insert_into_select.asp) and wanted to know that Denodo does not support it. Will it be supported in future?
user
14-10-2021 05:29:37 -0400
Hi I believe you need to [insert](https://community.denodo.com/docs/html/browse/latest/en/vdp/vql/inserts_updates_and_deletes_over_views/insert_statement/insert_statement#insert-statement) values of a specific column into the target view from the source view. In order to do this, you can use the following syntax where ViewA is the target view, ViewB is the source view and Field1 is the field: > INSERT INTO ViewB SELECT Field1 FROM ViewA In this scenario, you should provide the required** field name only in the Select statement**. Make note that the provided** field name should match the field in the Target view**. If not, you could use the alias name in the select statement as below: > INSERT INTO ViewB SELECT Field2 as Field1 FROM ViewA Hope this helps!
Denodo Team
18-10-2021 04:32:01 -0400
code
You must sign in to add an answer. If you do not have an account, you can register here