How to combine column values of one column into another column in MySQL?

Viewed 445

I need help in combining columns of one column into another column, specifically by just inserting the column values just under another column.

My objective here is that I want to acquire all the Date values from different tables(players table and penalties table) and just put them all together in just one column(without duplicates).

My issue here is that I can only combine them together through concatenating them (since I still have no idea how to combine them in a correct manner, I'm baffled between using JOINS (left or right), CONCAT, UNION(I can't use this since they have a different number of columns)).

   My query:
         -- 2
       SELECT
       DISTINCT(CONCAT(p.BIRTH_DATE,pl.PAYMENT_DATE)) AS ALL_DATE_VALUES

       FROM players p, penalties pl;

My query result: My query result

players table: Players table

penalties table: Penalties table

I know this seems a little bit simple but I'm just confused on what is indeed the right process/query of it(especially that I'm still learning the ropes of SQL).

Your responses and guides would really help me a lot! Thank you very much!!!!!

1 Answers

Use union:

select birth_date
from players
union    -- on purpose to remove duplicates
select payment_date
from penalties;
Related