Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 复制同一表中的记录_Sql - Fatal编程技术网

Sql 复制同一表中的记录

Sql 复制同一表中的记录,sql,Sql,我有一辆列着“车主”的汽车 我有一个车主,他有10辆车 现在我有另外两个人拥有相同的汽车,所以我需要在我的表中添加20条记录 只有一列不同: 比如: Insert into Cars (NameOfCar,NameOfOwner) Select NameOfCar,'"Robert Kubica' Where NameOfOwner='Schumacher'. Insert into Cars (NameOfCar,NameOfOwner) Select NameOfCar,'"Haka

我有一辆列着“车主”的汽车

我有一个车主,他有10辆车

现在我有另外两个人拥有相同的汽车,所以我需要在我的表中添加20条记录

只有一列不同:

比如:

Insert into Cars (NameOfCar,NameOfOwner) 
Select NameOfCar,'"Robert Kubica' Where NameOfOwner='Schumacher'. 

Insert into Cars (NameOfCar,NameOfOwner) 
Select NameOfCar,'"Hakashi Honda' Where NameOfOwner='Schumacher'. 

我发现您在查询中缺少FROM子句,请尝试添加它。

您缺少
FROM
子句:

Insert into cars (NameOfCar,NameOfOwner)
Select NameOfCar, 'Hakashi Honda'
From cars
Where NameOfOwner='Schumacher'

您的SQL应该可以工作-您的问题是什么?那么,上述两个语句的问题是什么?我怀疑在某个地方实际上存在一个问题,我想它的答案应该是“Insert into Cars(NameOfCar,NameOfOwner)Select c.NameOfCar,'Robert Kubica'From Cars AS c Where c.NameOfOwner='Schumacher'”虽然可能不完全如此。