简体   繁体   中英

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. 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

use UNION not JOIN, if you want to merge data. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM