tags:

views:

48

answers:

2

how to display multi table data in one page like facebook news feed. example tables /event,task/

i want to sort by datetime new in top.i can do it by php.i need mysql way /Sorry for my english/

  event.row1  
  task.row1
  event.row2  
  task.row2
  event.row3  
  task.row3
   ... 
  older
A: 

You can do it via MySQL

SELECT `AllData`.`id`, `AllData`.`date`
FROM
((SELECT `id`, `date` FROM `Events`)
UNION
(SELECT `id, `name` FROM `Tasks`)) `AllData`
ORDER BY `AllData`.`date`

You must have the same fields names to make the use, use AS to rename fields the same way in the request

Serty Oan
+1  A: 

Maybe you could create a virtual table pulling in all the required bits of the other tables?

Use CREATE VIEW syntax.

Leo