Skip to content

Instantly share code, notes, and snippets.

@marshallm
Created May 28, 2014 13:31
Show Gist options
  • Select an option

  • Save marshallm/b85b5872aa7a541dcdf1 to your computer and use it in GitHub Desktop.

Select an option

Save marshallm/b85b5872aa7a541dcdf1 to your computer and use it in GitHub Desktop.
SQL Format
SELECT message_id AS id,
subject,
is_read,
Date_format(sentDate, '%m/%d/%y') AS ts,
messagetypeid AS type
FROM (
SELECT message_id,
is_read
FROM message_user mu
WHERE user_id = 3784
AND label = 'Sent'
ORDER BY is_read ASC,id DESC
LIMIT 10
) o
JOIN message ON (message.messageId = o.message_id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment