I have the following three tables and I want to pull data out of them by the userid
, that is the one key field that gives them a relationship. I also want to pull the data in order by timestamp
Example of the table schema is below and what I have for a union query that is not working.
Table1: userid, event_id, event_name, timestamp
Table2: id_user, comment, timestamp
Table3: user_id, photo, timestamp
$result5 = mysql_query
("(SELECT event_name, timestamp FROM table1 WHERE userid = '25')
UNION ALL
(SELECT comment,timestamp FROM table2 WHERE id_user = '25')
UNION ALL
(SELECT photo,timestamp FROM table3 WHERE user_id ='25')
ORDER BY timestamp")
or die(mysql_error());