如何加入几个不相关的表 [英] How to join several unrelated tables

查看:136
本文介绍了如何加入几个不相关的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有五个查询,每个查询都会返回单列多行输出。我想编写一个包含所有这些查询的函数。

任何人都可以帮忙吗?

I have five queries and each of them will return me single column multiple row output. I want to to write a function which will contain all of these queries.
Can anyone help?

查询1:

Select Col1 as X from Table1;

查询2:

Select Col3 as Y from Table2;

从一个函数我想得到一个表,它将有列
X,Y

From a function I want to get a table which will have columns X, Y

如何在单个函数下使用这些查询?

How to club these queries under single function?

推荐答案

Use the UNION operator:

FROM
tbl_name_1
UNION ALL
SELECT
column_1
FROM
tbl_name_2;

这篇关于如何加入几个不相关的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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