Created
February 19, 2016 13:49
-
-
Save vetalt/3c7605dcae758aa8a3be to your computer and use it in GitHub Desktop.
getLatestByCategories2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
select | |
ft1.parent_category_id, | |
ft1.forum_topic_id, | |
ft1.subject, | |
ft1.url, | |
ft1.post_count, | |
ft1.last_forum_topic_create_date, | |
case when ft1.is_locked then 'locked' when tft.track_forum_topic_id is not null then 'tracked' else 'none' end as status, | |
if ( | |
ft1.create_date >= ifnull( | |
'2016-02-18 10:09:47', | |
date_sub( | |
curdate(), | |
interval 7 day | |
) | |
) | |
and ft1.forum_topic_id not in (448, 449, 451, 455), | |
1, | |
0 | |
) as new | |
from | |
forum_topic ft1 | |
join user u1 on ft1.user_id = u1.user_id | |
and u1.is_content_hidden = 0 | |
left join track_forum_topic tft on ft1.forum_topic_id = tft.forum_topic_id | |
and tft.user_id = ifnull(41, 0) | |
where | |
ft1.parent_category_id = 10 | |
and ft1.is_parent_topic = 1 | |
and ft1.post_count > 3 | |
and ft1.is_live = 1 | |
order by | |
ft1.last_forum_topic_create_date desc | |
limit | |
3 | |
) | |
union all | |
( | |
select | |
ft1.parent_category_id, | |
ft1.forum_topic_id, | |
ft1.subject, | |
ft1.url, | |
ft1.post_count, | |
ft1.last_forum_topic_create_date, | |
case when ft1.is_locked then 'locked' when tft.track_forum_topic_id is not null then 'tracked' else 'none' end as status, | |
if ( | |
ft1.create_date >= ifnull( | |
'2016-02-18 10:09:47', | |
date_sub( | |
curdate(), | |
interval 7 day | |
) | |
) | |
and ft1.forum_topic_id not in (448, 449, 451, 455), | |
1, | |
0 | |
) as new | |
from | |
forum_topic ft1 | |
join user u1 on ft1.user_id = u1.user_id | |
and u1.is_content_hidden = 0 | |
left join track_forum_topic tft on ft1.forum_topic_id = tft.forum_topic_id | |
and tft.user_id = ifnull(41, 0) | |
where | |
ft1.parent_category_id = 6 | |
and ft1.is_parent_topic = 1 | |
and ft1.post_count > 3 | |
and ft1.is_live = 1 | |
order by | |
ft1.last_forum_topic_create_date desc | |
limit | |
3 | |
) | |
union all | |
( | |
select | |
ft1.parent_category_id, | |
ft1.forum_topic_id, | |
ft1.subject, | |
ft1.url, | |
ft1.post_count, | |
ft1.last_forum_topic_create_date, | |
case when ft1.is_locked then 'locked' when tft.track_forum_topic_id is not null then 'tracked' else 'none' end as status, | |
if ( | |
ft1.create_date >= ifnull( | |
'2016-02-18 10:09:47', | |
date_sub( | |
curdate(), | |
interval 7 day | |
) | |
) | |
and ft1.forum_topic_id not in (448, 449, 451, 455), | |
1, | |
0 | |
) as new | |
from | |
forum_topic ft1 | |
join user u1 on ft1.user_id = u1.user_id | |
and u1.is_content_hidden = 0 | |
left join track_forum_topic tft on ft1.forum_topic_id = tft.forum_topic_id | |
and tft.user_id = ifnull(41, 0) | |
where | |
ft1.parent_category_id = 13 | |
and ft1.is_parent_topic = 1 | |
and ft1.post_count > 3 | |
and ft1.is_live = 1 | |
order by | |
ft1.last_forum_topic_create_date desc | |
limit | |
3 | |
) | |
union all | |
( | |
select | |
ft1.parent_category_id, | |
ft1.forum_topic_id, | |
ft1.subject, | |
ft1.url, | |
ft1.post_count, | |
ft1.last_forum_topic_create_date, | |
case when ft1.is_locked then 'locked' when tft.track_forum_topic_id is not null then 'tracked' else 'none' end as status, | |
if ( | |
ft1.create_date >= ifnull( | |
'2016-02-18 10:09:47', | |
date_sub( | |
curdate(), | |
interval 7 day | |
) | |
) | |
and ft1.forum_topic_id not in (448, 449, 451, 455), | |
1, | |
0 | |
) as new | |
from | |
forum_topic ft1 | |
join user u1 on ft1.user_id = u1.user_id | |
and u1.is_content_hidden = 0 | |
left join track_forum_topic tft on ft1.forum_topic_id = tft.forum_topic_id | |
and tft.user_id = ifnull(41, 0) | |
where | |
ft1.parent_category_id = 9 | |
and ft1.is_parent_topic = 1 | |
and ft1.post_count > 3 | |
and ft1.is_live = 1 | |
order by | |
ft1.last_forum_topic_create_date desc | |
limit | |
3 | |
) | |
union all | |
( | |
select | |
ft1.parent_category_id, | |
ft1.forum_topic_id, | |
ft1.subject, | |
ft1.url, | |
ft1.post_count, | |
ft1.last_forum_topic_create_date, | |
case when ft1.is_locked then 'locked' when tft.track_forum_topic_id is not null then 'tracked' else 'none' end as status, | |
if ( | |
ft1.create_date >= ifnull( | |
'2016-02-18 10:09:47', | |
date_sub( | |
curdate(), | |
interval 7 day | |
) | |
) | |
and ft1.forum_topic_id not in (448, 449, 451, 455), | |
1, | |
0 | |
) as new | |
from | |
forum_topic ft1 | |
join user u1 on ft1.user_id = u1.user_id | |
and u1.is_content_hidden = 0 | |
left join track_forum_topic tft on ft1.forum_topic_id = tft.forum_topic_id | |
and tft.user_id = ifnull(41, 0) | |
where | |
ft1.parent_category_id = 4 | |
and ft1.is_parent_topic = 1 | |
and ft1.post_count > 3 | |
and ft1.is_live = 1 | |
order by | |
ft1.last_forum_topic_create_date desc | |
limit | |
3 | |
) | |
union all | |
( | |
select | |
ft1.parent_category_id, | |
ft1.forum_topic_id, | |
ft1.subject, | |
ft1.url, | |
ft1.post_count, | |
ft1.last_forum_topic_create_date, | |
case when ft1.is_locked then 'locked' when tft.track_forum_topic_id is not null then 'tracked' else 'none' end as status, | |
if ( | |
ft1.create_date >= ifnull( | |
'2016-02-18 10:09:47', | |
date_sub( | |
curdate(), | |
interval 7 day | |
) | |
) | |
and ft1.forum_topic_id not in (448, 449, 451, 455), | |
1, | |
0 | |
) as new | |
from | |
forum_topic ft1 | |
join user u1 on ft1.user_id = u1.user_id | |
and u1.is_content_hidden = 0 | |
left join track_forum_topic tft on ft1.forum_topic_id = tft.forum_topic_id | |
and tft.user_id = ifnull(41, 0) | |
where | |
ft1.parent_category_id = 3 | |
and ft1.is_parent_topic = 1 | |
and ft1.post_count > 3 | |
and ft1.is_live = 1 | |
order by | |
ft1.last_forum_topic_create_date desc | |
limit | |
3 | |
) | |
union all | |
( | |
select | |
ft1.parent_category_id, | |
ft1.forum_topic_id, | |
ft1.subject, | |
ft1.url, | |
ft1.post_count, | |
ft1.last_forum_topic_create_date, | |
case when ft1.is_locked then 'locked' when tft.track_forum_topic_id is not null then 'tracked' else 'none' end as status, | |
if ( | |
ft1.create_date >= ifnull( | |
'2016-02-18 10:09:47', | |
date_sub( | |
curdate(), | |
interval 7 day | |
) | |
) | |
and ft1.forum_topic_id not in (448, 449, 451, 455), | |
1, | |
0 | |
) as new | |
from | |
forum_topic ft1 | |
join user u1 on ft1.user_id = u1.user_id | |
and u1.is_content_hidden = 0 | |
left join track_forum_topic tft on ft1.forum_topic_id = tft.forum_topic_id | |
and tft.user_id = ifnull(41, 0) | |
where | |
ft1.parent_category_id = 11 | |
and ft1.is_parent_topic = 1 | |
and ft1.post_count > 3 | |
and ft1.is_live = 1 | |
order by | |
ft1.last_forum_topic_create_date desc | |
limit | |
3 | |
) | |
union all | |
( | |
select | |
ft1.parent_category_id, | |
ft1.forum_topic_id, | |
ft1.subject, | |
ft1.url, | |
ft1.post_count, | |
ft1.last_forum_topic_create_date, | |
case when ft1.is_locked then 'locked' when tft.track_forum_topic_id is not null then 'tracked' else 'none' end as status, | |
if ( | |
ft1.create_date >= ifnull( | |
'2016-02-18 10:09:47', | |
date_sub( | |
curdate(), | |
interval 7 day | |
) | |
) | |
and ft1.forum_topic_id not in (448, 449, 451, 455), | |
1, | |
0 | |
) as new | |
from | |
forum_topic ft1 | |
join user u1 on ft1.user_id = u1.user_id | |
and u1.is_content_hidden = 0 | |
left join track_forum_topic tft on ft1.forum_topic_id = tft.forum_topic_id | |
and tft.user_id = ifnull(41, 0) | |
where | |
ft1.parent_category_id = 8 | |
and ft1.is_parent_topic = 1 | |
and ft1.post_count > 3 | |
and ft1.is_live = 1 | |
order by | |
ft1.last_forum_topic_create_date desc | |
limit | |
3 | |
) | |
union all | |
( | |
select | |
ft1.parent_category_id, | |
ft1.forum_topic_id, | |
ft1.subject, | |
ft1.url, | |
ft1.post_count, | |
ft1.last_forum_topic_create_date, | |
case when ft1.is_locked then 'locked' when tft.track_forum_topic_id is not null then 'tracked' else 'none' end as status, | |
if ( | |
ft1.create_date >= ifnull( | |
'2016-02-18 10:09:47', | |
date_sub( | |
curdate(), | |
interval 7 day | |
) | |
) | |
and ft1.forum_topic_id not in (448, 449, 451, 455), | |
1, | |
0 | |
) as new | |
from | |
forum_topic ft1 | |
join user u1 on ft1.user_id = u1.user_id | |
and u1.is_content_hidden = 0 | |
left join track_forum_topic tft on ft1.forum_topic_id = tft.forum_topic_id | |
and tft.user_id = ifnull(41, 0) | |
where | |
ft1.parent_category_id = 14 | |
and ft1.is_parent_topic = 1 | |
and ft1.post_count > 3 | |
and ft1.is_live = 1 | |
order by | |
ft1.last_forum_topic_create_date desc | |
limit | |
3 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment