View difference between Paste ID: 1XS4EEMS and Fa1r8CEm
SHOW: | | - or go back to the newest paste.
1-
select * from (
1+
select 
2
  if(cm.comment_approved = '1' and cm.user_id > 0, cm_u.display_name, ps_u.display_name) as display_name,
3-
	if(com.comment_approved = '1' and com.user_id > 0, com_u.display_name, u.display_name) as display_name,
3+
  cm.comment_author,
4-
	com.comment_author,
4+
  a.title as title,
5-
	if(p.post_type = 'reply', t.post_title, p.post_title) as title,
5+
  if(cm.comment_approved = '1', cm.comment_ID, pst.ID) as post_id,
6-
	if(com.comment_approved = '1', com.comment_ID, p.ID) as post_id,
6+
  if(cm.comment_approved = '1', cm.user_id, pst.post_author) as author_id,
7-
	if(com.comment_approved = '1', com.user_id, p.post_author) as author_id,
7+
  a.max_post_date as post_date,
8-
	if(com.comment_approved = '1', unix_timestamp(com.comment_date), unix_timestamp(p.post_date)) as post_date,
8+
  if(cm.comment_approved = '1', SUBSTRING(cm.comment_content, 1, 200), SUBSTRING(pst.post_content, 1, 200)) as content,
9-
	if(com.comment_approved = '1', SUBSTRING(com.comment_content, 1, 200), SUBSTRING(p.post_content, 1, 200)) as content,
9+
  if(cm.comment_approved = '1', 'comment', pst.post_type) as type,
10-
	if(com.comment_approved = '1', 'comment', p.post_type) as type,
10+
  if(pst.post_type = 'reply', ifnull(pst.post_parent,0), pst.ID) as post_parent
11-
	if(p.post_type = 'reply', ifnull(p.post_parent,0), p.ID) as post_parent,
11+
from (
12-
        max(post_date) as max_post_date
12+
13
        if(p.post_type = 'reply', t.post_title, p.post_title) as title,
14-
LEFT JOIN `wp_users` as u on u.ID = p.post_author
14+
15
        if(com.comment_approved = '1', unix_timestamp(com.comment_date), unix_timestamp(p.post_date)) as post_date,
16
        if(p.post_type = 'reply', ifnull(p.post_parent,0), p.ID) as post_parent,
17-
LEFT JOIN `wp_users` as com_u on com_u.ID = com.user_id
17+
        max(if(com.comment_approved = '1', unix_timestamp(com.comment_date), unix_timestamp(p.post_date))) as max_post_date,
18
        max(if(com.comment_approved = '1', com.comment_ID, p.ID)) as max_post_id
19-
	AND p.post_status = 'publish'
19+
20-
	AND p.post_content <> '')
20+
21-
	OR com.comment_approved = '1'
21+
22-
GROUP BY post_parent)
22+
23-
ORDER BY max_post_date DESC
23+
        AND p.post_status = 'publish'
24-
LIMIT 0,12
24+
        AND p.post_content <> '')
25
        OR com.comment_approved = '1'
26
group by post_parent) a
27
LEFT JOIN `wp_posts` as pst on a.max_post_id = pst.id
28
LEFT JOIN `wp_comments` as cm on a.max_post_id = cm.comment_post_ID
29
LEFT JOIN `wp_users` as cm_u on cm_u.ID = cm.user_id
30
LEFT JOIN `wp_users` as ps_u on ps_u.ID = pst.post_author
31
order by max_post_date desc
32
limit 0,12