将数据从一个表转移到另一表 [英] transfer data from one table to another table

查看:59
本文介绍了将数据从一个表转移到另一表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将值从一个表转移到另一张表.
在这里,代码正在执行,但是会插入到单独的行中. 请告知如何检查插入特定行的条件.

插入test1(photo),从dbo.test test1中选择内容,其中ID = 1"

在此代码中,包含从特定行中获取值的位置

I need to transfer value from one table to another table.
Here, the code is executing but it inserting into separate row..
pls tel how to check the where condition for inserting into particular row.

"insert into test1(photo) select content from dbo.test test1 where ID = 1"

In this code containing where for getting value from particular row

推荐答案

,您无法使用插入查询覆盖任何现有行.

相反,您可以对其进行更新,也可以在更新连接查询到的帮助下进行.

谢谢,
Jitendra Kumar
you can not override any existing row with insert query.

Insteade you can update the same and you can do it with help of update join query to.

Thanks,
Jitendra Kumar


解决方案:

使用内部联接进行更新查询
此处的示例查询:

Solution:

Make a update query with inner join
example query here:

update dbo.test1  set photo=t.content from dbo.test1 as t1 inner join dbo.test as t on t1.regno='13'


这篇关于将数据从一个表转移到另一表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆