在SQL中组合表并插入新行 [英] Combing Tables In SQL and Inserting New Rows

查看:77
本文介绍了在SQL中组合表并插入新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在SQL中组合两个表,其中表A和表B中的前五列具有相同的键字段,但表B还有一个键字段,它们与重复字段具有相同的信息。表A至E列在表
A和B中,但表A仅根据YRMODAY列A为每个义务号(列D)有一行。列F键字段来自表B并有两行对于相同的义务编号。我想知道怎么做是从表
B中插入列F,它将插入一行以再次允许列A到E.然后最终复制列G并从表B中添加与表B中的列F相关的列H和I.我在考虑如何执行此操作时遇到很多困难并且
确实可以使用一些帮助。

I'm trying to combine two tables in SQL where the first five columns in Table A and Table B have the same key fields but Table B has one more key field that keeps from having the same information as being duplicates. columns A through E are in both Table A and B but Table A only has one row for each Obligation Number (column D) based on the YRMODAY column A. Column F a key field is from Table B and has two rows for the same obligation number. What I would like to know how to do is insert column F from Table B where it will insert a row to allow for column A through E again. Then ultimately copy down column G and add columns H and I from Table B that correlate with column F from Table B. I'm having a lot of trouble contemplating how I go about doing this and could really use some help.

推荐答案

Hi
wymer2020

 

感谢您的发布。

 

我是害怕我可能会通过你的描述了解你的要求。  confused
根据您的帖子,您有
两张表
许多
首先表A和表B中的五列具有相同的
名称。表A中的列D是i 识别列 ,它可能与表B中的列F有关。 b $ b 这就是我理解你所说的内容

I am afraid that I might be confused about your requirement through your description .  According to your posting , you have two tables with many columns and first five columns in Table A and Table B have the same name. The column D in Table A is identification column which might be related to column F in Table B. That's the part I understand what you're saying.

 

如果我有任何不正确的理解,请告诉我。你可以 
请与您分享您的餐桌结构和一些样本数据以及您的预期结果 这样我们就可以 b 明确了解 获得正确的方向并进行一些测试。

 

最好的问候,

Rachel


这篇关于在SQL中组合表并插入新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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