I have 2 table in my database. They are admin action table and user action. And have table structure as follows ::
Admin Action table
Action_id | order | Action_type | timestamp |
1 12 pending 2014-07-24 15:30:45
2 12 packing 2014-08-24 14:12:11
3 12 shipping 2013-05-01 15:55:12
4 12 packing 2011-11-25 21:10:22
User Action table
Action_id | order | Action_type | timestamp |
1 12 transfer 2014-07-22 15:30:45
2 12 transfer 2014-09-23 14:12:11
3 12 transfer 2013-05-07 15:55:12
4 12 transfer 2011-11-28 21:10:22
I want to sort timestamp both table. What is come before or after? And Finally. There will be result as follows:
Activity table
Action_id | Action_type | timestamp |
4 packing 2011-11-25 21:10:22 //admin action
4 transfer 2011-11-28 21:10:22 //user aciton
3 shipping 2013-05-01 15:55:12 //admin action
3 transfer 2013-05-07 15:55:12 //user aciton
1 transfer 2014-07-22 15:30:45 //user aciton
1 pending 2014-07-24 15:30:40 //admin action
.....
What is MySQL command to slove this?
I know I can coding an algorithm in PHP for sort timestamp. But I think if good query from database. It helps to make it easy to handle in the next step.
ORDER BY timestamp DESC? But it's hard to see what you are trying to do.