从多个表中选择没有联接? [英] Select from multiple tables without a join?

查看:76
本文介绍了从多个表中选择没有联接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最简单的方法是从两个表中选择数据,而不是将它们连接在一起,而是将它们显示为单独的行.这两个表都有相似或匹配的字段,我想在它们上运行一些聚合函数,例如对两个表中同一月份发生的所有行进行平均.

What is the easiest way to select data from two tables and rather than join them, have them appear as separate rows. Both tables have similar or matching fields and I want to run some aggregate function on them such as avg all the rows that occurred in the same month, from both tables.

例如,我有两个表,一个表显示来自一个系统的事务,另一个表显示来自不同系统的事务.有没有办法将两个表中的所有事务都作为单独的行来获取?如果表1有20条记录,表2有30条记录,我希望返回的行数为50.

for example I have two tables, one that is shows transactions from one system and another with transactions from a different system. Is there a way to grab all the transactions from both tables as separate rows? if table 1 had twenty records and table 2 have thirty records, I'd like there to be 50 rows on the return.

推荐答案

您可以尝试以下方法:

SELECT f1,f2,f3 FROM table1
UNION
SELECT f1,f2,f3 FROM table2

这篇关于从多个表中选择没有联接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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