mysql - Merge two columns in different tables -
i have 2 table,
project
----------------------- id | name | created ----------------------- 1 | p1 | 2015-05-05 2 | p2 | 2015-04-29 3 | p3 | 2015-05-07
task
------------------------ id | name | created ------------------------ 1 | t1 |2015-05-04 2 | t2 |2015-04-30 3 | t3 |2015-05-06
i want table.
last actions
-------------------------- type |name | created -------------------------- p | p3 | 2015-05-07 t | t3 | 2015-05-06 p | p1 | 2015-05-05 t | t1 | 2015-05-04 t | t2 | 2015-04-30 p | p2 | 2015-04-29
p - project type , t - task type
how can data?
perhaps easiest way union all
select * ( select 'p' type, name, created project union select 't' type, name, created task )x order created desc
Comments
Post a Comment