使用游标的两个选择查询,需要填充单个表 [英] Two select queries using cursor, required to fill single table

查看:87
本文介绍了使用游标的两个选择查询,需要填充单个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有2个选择语句。

我必须使用游标将这些值插入单个表格。



例如:

TableA

S.No.姓名

1姓名1

2姓名2

...



TableB

DateOfBirth FatherName

10-2-1988 FatherName1

10-9-1989 FatherName2

...





预计:

名称FatherName

Name1 FatherName1

Name2 FatherName2

...



在TableA中选择Name的一个选择查询,在TableB中选择FatherName的其他查询。 />
最后将这两个字段插入到具有Name和FatherName的第三个表中。

Hi I have 2 select statements.
I have to use cursor to insert those values into single table.

For Example:
TableA
S.No. Name
1 Name1
2 Name2
...

TableB
DateOfBirth FatherName
10-2-1988 FatherName1
10-9-1989 FatherName2
...


Expected:
Name FatherName
Name1 FatherName1
Name2 FatherName2
...

One select query for selecting Name in TableA, other query for selecting FatherName in TableB.
Finally these two fields to be inserted into third table which has Name and FatherName.

推荐答案

TableA

S.没有。姓名

1姓名1

2姓名2

...



TableB

DateOfBirth FatherName S.no

10-2-1988 FatherName1 1

10-9-1989 FatherName2 2



从表格中选择姓名,父姓名

内部联接表格

tablea。[s.no] = tableb。[s.no]



创建这样的表并提供关系
TableA
S.No. Name
1 Name1
2 Name2
...

TableB
DateOfBirth FatherName S.no
10-2-1988 FatherName1 1
10-9-1989 FatherName2 2

select name,fathername from tablea
inner join tableb on
tablea.[s.no]=tableb.[s.no]

Create a tables like this and to provide a relationship


这篇关于使用游标的两个选择查询,需要填充单个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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