如何从其他表中搜索相关信息并填写。 [英] How to search the related information from other table and fill it .

查看:89
本文介绍了如何从其他表中搜索相关信息并填写。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张表EMP,员工的所有信息都在那里。

EMP栏目是:



EMPID

Lname

Fname

部门

指定





我还有一个名为info的表。

信息栏是:

Empid

fname

payrment



EMP.EMPID = Info.EMPID



信息表EMPID随机来自其他table.Now在Info表中只有EMPID,所以我想从EMP表填充信息表的其他列,其EMPID出现在Info表中...

解决方案

< blockquote>你的问题对我来说并不清楚。

如果要通过EMP表的数据更新信息表,可以使用update~from查询。



在Normalize视点中,你不应该在不同的表中存储相同的数据。


试试这段代码。



  update  i 
set fname = e.Fname,departrment = e.Department
from emp e,Info i
其中 e.Empid = i.Empid


I have one table EMP where all information of employee are there.
EMP columns are:

EMPID
Lname
Fname
Department
Designation


And i have one more table called info.
Info columns are:
Empid
fname
departrment

EMP.EMPID=Info.EMPID

In info table EMPID are coming randomly from other table.Now in Info table only EMPID is there,so i want to fill other column of info table from EMP table whose EMPID is present on Info table...

解决方案

Your question is not clear for me.
If you want to update info table by EMP table's data, you can use "update ~ from" query.

In Normalize viewpoint, you should not store same data in different table.


Try this code.

update  i
 set fname=e.Fname,departrment=e.Department
 from emp e , Info i
 where e.Empid= i.Empid


这篇关于如何从其他表中搜索相关信息并填写。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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