本文介绍了从SQL Server 2005和2008中的两个表中获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友

我有两个表t1和t2.

表t1结构

支付码
名称

表t2的结构

支付码
名称

还有一件事,我的表中没有主键和外键的概念.

t1中的记录

1)111 sunil
2)222 sunit

t2中的记录

1)333 narayan
2)444 sumit

我想要查询中的所有记录.............

请尽快帮助我.

Dear Friends

I have two tables t1 and t2.

Table t1 Structure

Paycode
Name

Table t2 Structure

Paycode
Name

And one more thing there is no concept of primary key and foreign key in my table.

Records in t1

1) 111 sunil
2) 222 sunit

Records in t2

1) 333 narayan
2) 444 sumit

and I want all the records from query.............

Please help me out as soon as possible.

推荐答案

select * from t1 UNION ALL select * from t2


SELECT *
FROM t1
UNION ALL
SELECT *
FROM t2



了解更多:
文字查询-基础知识 [ ^ ]
选择 [ ^ ]
选择示例 [ ^ ]
UNION [ ^ ]
订购 [ ^ ]



Read more:
Writing queries - basics[^]
SELECT[^]
SELECT Examples[^]
UNION[^]
ORDER BY[^]



这篇关于从SQL Server 2005和2008中的两个表中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 08:43