的引用timestamp应该带有反引号,否则 MySQL 将假定一个字符串文字值。  
否则,要返回来自用户和所有朋友的消息,您可以使用UNION. 一半返回用户的消息,另一半返回朋友的消息。您需要将用户的电子邮件添加到您的加入条件:
/* First part of the UNION returns friends messages */
SELECT
  `timestamp`, 
  user, 
  content 
FROM
  messages 
  /* The join ON clause specifies the main user email */
  INNER JOIN friends 
    ON messages.user = friends.friend
       AND friends.email = 'email@example.com'
UNION ALL
/* Other part of the UNION just gets all messages for the main user by email addr */
SELECT
  `timestamp`,
  user,
  content
FROM
  messages
WHERE user = 'email@example.com'
/* ORDER BY applies to everything */
ORDER BY `timestamp` DESC;
如果你想在这里加入users信息(firstname/lastname),最简单的方法是将整个事情包装在一个子查询中并加入。
SELECT
  users.*,
  messages_sub.content,
  messages_sub.`timestamp`
FROM
  users
  JOIN (/* The entire thing from above */) AS messages_sub ON users.email = messages_sub.user
ORDER BY `timestamp`
也可以使用UNION您要查找的文字电子邮件地址和朋友列表来完成,只产生一个外部查询。这有点棘手,但最终可能会更快。从这里的表中引入其他列也不会那么混乱users。我将添加名称:
SELECT
  `timestamp`,
  user,
  firstname,
  lastname,
  content
FROM
  messages
  INNER JOIN (
    /* Union query produces a list of email addrs - 
       the person you're looking for plus all his friends
       Starts with string literal for the main user
    */
    SELECT 'email@example.com' AS email
    UNION 
    /* Plus all his friends into one list joined against messages */
    SELECT friend AS email FROM friends WHERE email = 'email@example.com'
  ) user_and_friends ON messages.user = user_and_friends.email
  /* Join against the users table for name info */
  INNER JOIN users ON user_and_friends.email = users.email
ORDER BY `timestamp` DESC