Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to append two columns into one column in SQL?

I have two columns in my Table called as Workers - Technicians. In Workers I have name of workers, and in Technicians I have name of technicians who is working in company. Here is how it looks:

Workers                              Technicians

Andy                  Kevin
Conan                 Jason
Jay                   Ray
Donald                Daryl
Martin                .
Mark                  .(rows goes on)
.
.(rows goes on)       

What I want to do is to append these rows and having a column called Employees. Here what i want:

Employees

Andy                  
Conan                 
Jay                   
Donald               
Martin                
Mark
Kevin
Jason
Ray
Daryl
.
.

I don't want to create another table, I just want to add a new column. How would i do this?

like image 468
LuckySlevin Avatar asked Nov 06 '11 18:11

LuckySlevin


1 Answers

An union statement should do the job here. Something like this:

 select Name from Workers-Technitians where Worker not null
 UNION 
 select Name from Workers-Technitians where Technitian not null

Keep in mind that both queries must have an equal column count when using an union

like image 164
Martin Taleski Avatar answered Oct 04 '22 22:10

Martin Taleski