gpt4 book ai didi

sql - 邮政系统 |如何将两个或多个表合并为一个表

转载 作者:行者123 更新时间:2023-11-29 13:45:10 25 4
gpt4 key购买 nike

我有很多数据被分成两个或多个表。然后如何从所有表中获取数据。

第一个表是点表,分三部分

first table = ab_p1_point
second table = ab_p2_point
third table = ab_p3_point

另一个表是折线表,又分为三部分

first table = bc_p1_line
second table = bc_p2_line
third table = bc_p3_line

如何将点表的所有部分组合成单点表,将线表的所有部分组合成单线表,而不是在两个表之间进行运算。

最佳答案

假设所有三个表都具有相同的结构,您可能会使用union all:

select * from (
select f1, f2, f3 from ab_p1_point
union all
select f1, f2, f3 from ab_p2_point
union all
select f1, f2, f3 from ab_p3_point
) t
where f1 = 'abc'

您可以通过将查询放入 View 中来使其更易于使用。

但是为什么要在多个表中拆分行?

关于sql - 邮政系统 |如何将两个或多个表合并为一个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49725824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com