合并多个结果集(SQL 查询结果 / 数据集)常见有几种方式,取决于你使用的数据库或编程语言。下面按最常见场景说明。
SELECT col1, col2 FROM table_a
UNION
SELECT col1, col2 FROM table_b;
✅ 特点:
SELECT col1, col2 FROM table_a
UNION ALL
SELECT col1, col2 FROM table_b;
✅ 特点:
SELECT a.col1, b.col2
FROM table_a a
JOIN table_b b ON a.id = b.id;
✅ 用于:
=VSTACK(Sheet1!A2:A100, Sheet2!A2:A100)
import pandas as pd
df = pd.concat([df1, df2, df3], ignore_index=True)
df = pd.concat([df1, df2]).drop_duplicates()
df = pd.merge(df1, df2, on='id', how='left')
UNION ALLJOINUNION(去重慢)如果你能告诉我:
我可以直接给你可执行的示例语句。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。