Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 0.57 KB  |  hits: 12  |  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. How can I merge these MySQL queries into one or reduce the number of queries (queries in a loop)
  2. SELECT m.id, m.type, m.user_id, m.content, m.date, m.privacy, u.username
  3. FROM messages m, users u WHERE m.user_id=? AND m.author=u.id AND
  4. ORDER by s.date DESC
  5. LIMIT 0, 30
  6.        
  7. SELECT c.id, c.author_id, c.content, c.date, u.username
  8. FROM comments c, users u
  9. WHERE c.message_id =? AND c.author_id=u.id
  10. ORDER BY c.date ASC
  11.        
  12. SELECT c.id, c.author_id, c.content, c.date, u.username
  13. FROM comments_to_comments c, users u
  14. WHERE c.comment_id =? AND c.author_id=u.id
  15. ORDER BY c.date ASC