SELECT
content_type,
content_order,
id,
title,
subtitle,
old_id,
image,
image_id,
intro_text,
intro_text_output,
date_created,
time_created,
author_id,
author_name,
section_name,
section_id
FROM (
(SELECT
('article') as content_type,
(1) as content_order,
ar.id as id,
ar.title as title,
ar.subtitle,
ar.old_id,
ar.image,
ar.image_id,
ar.intro_text,
ar.intro_text_output,
ar.date_created,
ar.time_created,
ar.author_id as author_id,
au.author_name as author_name,
ars.section_name,
ars.id as section_id
FROM
cont_articles ar
LEFT JOIN
cont_authors au
ON
ar.author_id = au.id
LEFT JOIN
cont_sections as ars
ON
ar.section_id = ars.id
WHERE
( MATCH(ar.title) AGAINST ('>' IN BOOLEAN MODE) ) AND active = 1
)UNION(
SELECT
('article') as content_type,
(20) as content_order,
ar.id as id,
ar.title as title,
ar.subtitle,
ar.old_id,
ar.image,
ar.image_id,
ar.intro_text,
ar.intro_text_output,
ar.date_created,
ar.time_created,
ar.author_id as author_id,
au.author_name as author_name,
ars.section_name,
ars.id as section_id
FROM
cont_articles ar
LEFT JOIN
cont_authors au
ON
ar.author_id = au.id
LEFT JOIN
cont_sections as ars
ON
ar.section_id = ars.id
WHERE
( MATCH(au.author_name) AGAINST ('>' IN BOOLEAN MODE) ) AND active = 1
)UNION(
SELECT
('article') as content_type,
(10) as content_order,
ar.id as id,
ar.title as title,
ar.subtitle,
ar.old_id,
ar.image,
ar.image_id,
ar.intro_text,
ar.intro_text_output,
ar.date_created,
ar.time_created,
ar.author_id as author_id,
au.author_name as author_name,
ars.section_name,
ars.id as section_id
FROM
cont_articles ar
LEFT JOIN
cont_authors au
ON
ar.author_id = au.id
LEFT JOIN
cont_sections as ars
ON
ar.section_id = ars.id
WHERE
( MATCH(ar.subtitle) AGAINST ('>' IN BOOLEAN MODE) ) AND active = 1
)UNION(
SELECT
('blog') as content_type,
(2) as content_order,
ar.id as id,
ar.title as title,
('') as subtitle,
ar.old_id,
ar.have_image as image,
ar.image_id,
ar.content as intro_text,
ar.content_output as intro_text_output,
ar.date_created,
ar.time_created,
ar.author_id as author_id,
au.author_name as author_name,
ars.section_name,
ars.id as section_id
FROM
users_blogs ar
LEFT JOIN
cont_authors au
ON
ar.author_id = au.id
LEFT JOIN
blogs_sections as ars
ON
ar.section_id = ars.id
WHERE
( MATCH(ar.title) AGAINST ('>' IN BOOLEAN MODE) ) AND active = 1
)UNION(
SELECT
('blog') as content_type,
(21) as content_order,
ar.id as id,
ar.title as title,
('') as subtitle,
ar.old_id,
ar.have_image as image,
ar.image_id,
ar.content as intro_text,
ar.content_output as intro_text_output,
ar.date_created,
ar.time_created,
ar.author_id as author_id,
au.author_name as author_name,
ars.section_name,
ars.id as section_id
FROM
users_blogs ar
LEFT JOIN
cont_authors au
ON
ar.author_id = au.id
LEFT JOIN
blogs_sections as ars
ON
ar.section_id = ars.id
WHERE
( MATCH(au.author_name) AGAINST ('>' IN BOOLEAN MODE) ) AND active = 1
)UNION(
SELECT
('article') as content_type,
(23) as content_order,
ar.id as id,
ar.title as title,
ar.subtitle,
ar.old_id,
ar.image,
ar.image_id,
ar.intro_text,
ar.intro_text_output,
ar.date_created,
ar.time_created,
ar.author_id as author_id,
au.author_name as author_name,
ars.section_name,
ars.id as section_id
FROM
cont_articles ar
LEFT JOIN
cont_authors au
ON
ar.author_id = au.id
LEFT JOIN
cont_sections as ars
ON
ar.section_id = ars.id
WHERE
( MATCH(ar.intro_text_output) AGAINST ('>' IN BOOLEAN MODE) ) AND active = 1
)UNION(
SELECT
('article') as content_type,
(25) as content_order,
ar.id as id,
ar.title as title,
ar.subtitle,
ar.old_id,
ar.image,
ar.image_id,
ar.intro_text,
ar.intro_text_output,
ar.date_created,
ar.time_created,
ar.author_id as author_id,
au.author_name as author_name,
ars.section_name,
ars.id as section_id
FROM
cont_articles ar
LEFT JOIN
cont_authors au
ON
ar.author_id = au.id
LEFT JOIN
cont_sections as ars
ON
ar.section_id = ars.id
WHERE
( MATCH(ar.content_output) AGAINST ('>' IN BOOLEAN MODE) ) AND active = 1
)UNION(
SELECT
('blog') as content_type,
(24) as content_order,
ar.id as id,
ar.title as title,
('') as subtitle,
ar.old_id,
ar.have_image as image,
ar.image_id,
ar.content as intro_text,
ar.content_output as intro_text_output,
ar.date_created,
ar.time_created,
ar.author_id as author_id,
au.author_name as author_name,
ars.section_name,
ars.id as section_id
FROM
users_blogs ar
LEFT JOIN
cont_authors au
ON
ar.author_id = au.id
LEFT JOIN
blogs_sections as ars
ON
ar.section_id = ars.id
WHERE
( MATCH(ar.content_output) AGAINST ('>' IN BOOLEAN MODE) ) AND active = 1
)) ToTal
GROUP BY
id
ORDER BY
content_order ASC,
date_created DESC,
time_created DESC,
title ASC