Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jun 16th, 2011  |  syntax: None  |  size: 0.91 KB  |  views: 47  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. SELECT STRAIGHT_JOIN
  2.       PreQuery.MessageID,
  3.       mh.Type,
  4.       mh.Subject,
  5.         mr.isread,
  6.       md.from_UserID,
  7.       md.body,
  8.       md.timestamp,
  9.       u.firstname,
  10.       u.lastname,
  11.       u.gender,
  12.       u.avatar
  13.    from
  14.       ( SELECT md.messageid,
  15.               MAX( md.DtlID ) as LastDetail
  16.            from
  17.               message_detail md                            
  18.            group by
  19.               md.messageID ) PreQuery
  20.  
  21.         JOIN message_recipient mr
  22.          ON PreQuery.MessageID = mr.MessageID
  23.  
  24.       JOIN message_header mh
  25.          ON PreQuery.MessageID = mh.MessageID
  26.  
  27.       JOIN message_detail md
  28.          ON PreQuery.LastDetail = md.DtlID
  29.          JOIN users u
  30.             on md.from_userid = u.userid
  31.  
  32.                 where
  33.                   mr.userid = 5
  34.               and mr.isspam = '0'
  35.               and mr.isdelete = '0'
  36.  
  37.    group by mr.messageid
  38.  
  39.    order by
  40.       md.timestamp desc
clone this paste RAW Paste Data