[英]Subqueries for PostgreSQL returns syntax error near select
I am a beginner to database, and I am trying to run a subquery to insert data from one table to another one with identical schema.我是数据库的初学者,我正在尝试运行一个子查询以将数据从一个表插入到另一个具有相同架构的表中。
insert into tbl_technologies_used (t_name_tech, t_category_tech, i_rating)
values (
select t_name_tech, t_category_tech, i_rating
from tbl_technologies_proposed
);
But I got this error:但我得到了这个错误:
ERROR: syntax error at or near "select"
LINE 1: ... (t_name_tech, t_category_tech, i_rating) values (select t_n...
How can I fix this issue?我该如何解决这个问题? I have checked my code again and again, but I can't find out the error.
我一遍又一遍地检查我的代码,但我找不到错误。
If the source of an INSERT is a SELECT, you can't use VALUES
:如果 INSERT 的来源是 SELECT,则不能使用
VALUES
:
insert into tbl_technologies_used (t_name_tech, t_category_tech, i_rating)
select t_name_tech, t_category_tech, i_rating
from tbl_technologies_proposed
The values
clause provides a static set of rows which is not needed as the rows to be inserted come from your SELECT statement. values
子句提供了一组不需要的行 static,因为要插入的行来自您的 SELECT 语句。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.