如何使用sql union在单个查询中获取具有不同列的两个表的值 [英] How to get tall the values of two table with different columns in single query using sql union

查看:529
本文介绍了如何使用sql union在单个查询中获取具有不同列的两个表的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用sql union

How to get tall the values of two table with different columns in single query using sql union

推荐答案

LECT column_name(s) FROM table1
UNION
SELECT column_name(s) FROM table2;
Note: The UNION operator selects only distinct values by default. To allow duplicate values, use the ALL keyword with UNION.

SQL UNION ALL Syntax

SELECT column_name(s) FROM table1
UNION ALL
SELECT column_name(s) FROM table2;


这篇关于如何使用sql union在单个查询中获取具有不同列的两个表的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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