简体   繁体   English

在给定条件下将行从源表复制到新表

[英]Copy rows from source table to new table given condition

I use the following code but the program gives out an error and does not work: 我使用以下代码,但该程序发出错误,但不起作用:

INSERT INTO dest
SELECT *
FROM source
WHERE source.var="value";

I want to copy all rows and columns from the source table into the destination table given a condition. 我想在给定条件的情况下将源表中的所有行和列复制到目标表中。 How do I solve this? 我该如何解决这个问题?

Try this query using SELECT INTO . 使用SELECT INTO尝试此查询。 It will create new table and add rows to it. 它将创建新表并向其添加行。

SELECT *
INTO dest
FROM source
WHERE source.var="value";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将一些行从一个表复制到另一个新表 - copy some rows from one table to another new table 将新行插入表中,但从表中的另一行复制数据 - Insert new rows into table but copy data from another row in the table MySQL:如何通过跳过源表中的空行将行从一个表复制到另一个表? - MySQL: How to copy row from one table to another with skipping empty rows in source table? 将表格中的行复制到几乎相同的表格中 - Copy rows from a table into a near identical table 如何根据Sybase中的某些条件从另一个表的新表中插入行? - How can I insert rows in a new table from another table based on some condition in Sybase? 如何在给定值集合的情况下从表中插入新行并删除缺失的行? - How can I insert new rows and delete missing rows from a table given a collection of values? 如何从表中选择与给定日期/日期条件匹配的所有行? - How to select all rows from a table which match a given date/date condition? 将数据从表中的行复制到同一表中的将来的行 - Copy data from rows in a table to future rows in same table 仅将选择的值从一个表复制到另一个表,并附带条件 - Copy only selected values from one table to another table with condition 根据条件从一个临时表复制到另一个临时表? - Copy from one temp table to another temp table on condition base?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM