SQL查询-选择与多个表不同 [英] Sql query- Select distinct from multiple tables

查看:323
本文介绍了SQL查询-选择与多个表不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须编写一个SQL查询来获取不同的位置.

我有3个表,即-tblA,tblB和tblC

所有表都包含用于存储位置"的列,但名称不同.
现在我想从这些表中选择不同的位置,有没有办法做到这一点.

tblA包含用于存储位置的"ALocation"列;
tblB包含用于存储位置的"BLocation"列;
tblC包含用于存储位置的"CLocation"列;

I have to write a sql query for fetching distinct locations.

I have 3 tables, namely- tblA, tblB, and tblC

All tables contain a column for storing ''location'' but with different names.
Now i want to select distinct location from these tables is there any way to do this.

tblA contain ''ALocation'' Column for storing location;
tblB contain ''BLocation'' Column for storing location;
tblC contain ''CLocation'' Column for storing location;

推荐答案

Try:

Try:

SELECT  ALocation  from tblA
UNION
SELECT  BLocation  from tblb
UNION
SELECT  CLocation  from tblC


这篇关于SQL查询-选择与多个表不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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