查询多个表以从两个表的单个列中获得相同的列名VoucherNo [英] query to multiple tables to get same column name VoucherNo in single column from both tables

查看:87
本文介绍了查询多个表以从两个表的单个列中获得相同的列名VoucherNo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

使用两个表
1. tbl_Cash现金帐户
2. tbl_Bank银行帐户

这两个表使用2个不同的列,且具有相同的名称VoucherNo.但是那样的价值是不同的

现金券号CB/P/201210160001
银行凭单编号BB/R/201210160001

有一个网格,其中列VoucherNo.应该同时显示两个较高的VoucherNo's

ID || VocuherNo ||日期|| AccountName
---------------------------------------
---------------------------------------
01 CB/P/201210160001 2012/10/15现金
02 BB/R/201210160001 2012/10/15银行

如何在数据库中查询以从两个表的单列中获取VoucherNo?

请指教

谢谢,

Hi All,

Using Two Table
1. tbl_Cash for Cash Accounts
2. tbl_Bank for Bank Accounts

Both tables using 2 different columns having same name VoucherNo. but value is diffrent like that

For Cash VoucherNo. CB/P/201210160001
For Bank VoucherNo. BB/R/201210160001

There is a grid where column VoucherNo. should show both upper VoucherNo''s Like that

ID || VocuherNo || Date || AccountName
---------------------------------------
---------------------------------------
01 CB/P/201210160001 10/15/2012 Cash
02 BB/R/201210160001 10/15/2012 Bank

How can i query in database to get VoucherNo in single column from both tables?

Please advice

Thanks,

推荐答案

一个联合体如下所示,可能会有所帮助.

A union All like shown below may help.

select VoucherNo as vNo from tbl_Cash
union all
select VoucherNo as vNo from tbl_Bank



希望有帮助,如果确实将其标记为答案/赞扬
谢谢,
Milind



Hope that helps, If it does mark it as answer/upvote
Thanks,
Milind


解决了自己:)

Solved Myself :)

SELECT VoucherNo into #A FROM tbl_Bank

Insert into #A
Select VoucherNo from tbl_Cash

Select VoucherNo from #A


这篇关于查询多个表以从两个表的单个列中获得相同的列名VoucherNo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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