[英]How can I join one below the other (not fusioning/merging data) 3 columns from 3 different tables in SQL?
On Pentaho - Spoon I want to select and join 3 columns which are fields related to Date and named differently, from 3 different tables (one field from each table), and join all the data in one single column that will be called Date.在 Pentaho - Spoon 上,我想要 select 并从 3 个不同的表(每个表中的一个字段)连接 3 个与日期相关的字段并以不同方式命名的列,并将所有数据连接到一个名为 Date 的列中。 I tried to do it with a step but couldn't find it so I think the easiest way is to write the script.
我试着用一个步骤来做,但找不到它,所以我认为最简单的方法是编写脚本。 Any idea?
任何想法? I am lost...Thanks!!
我迷路了...谢谢!
I started with: SELECT dbo.SCHOOL.Date, dbo.STUDENT.Year, dbo.EXAMS.Year FROM dbo.SCHOOL, dbo.STUDENT, dbo.EXAMS我开始于:SELECT dbo.SCHOOL.Date, dbo.STUDENT.Year, dbo.EXAMS.Year FROM dbo.SCHOOL, dbo.STUDENT, dbo.EXAMS
use UNION not JOIN, if you want to merge data.如果要合并数据,请使用 UNION 而不是 JOIN。 If your all columns have the same data type (date).
如果您的所有列都具有相同的数据类型(日期)。
SELECT Date, 'SchoolTable' FROM dbo.School
UNION
SELECT Year, 'StudentTable' FROM dbo.Student
UNION
SELECT Year, 'ExamsTable' FROM dbo.Exams
or give more information about tables或提供有关表格的更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.