我有以下三个表,我想通过 从中提取数据userid
,这是赋予它们关系的一个关键字段。我还想按timestamp
下面的表模式示例以及我对不起作用的联合查询的示例来按顺序提取数据。
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());