1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| SELECT
DISTINCT(nl.`id_news`),
n.*,
nl.*,
LEFT(nl.`title`, 120) as title,
(
SELECT count(cn.`id_commentnews`)
FROM `table_commentnews` cn
WHERE cn.`news` = n.`id_news`
AND cn.`actif` = 1
) as count_comments,
n.`id_news` as `id`
FROM `table_news_lang` nl
LEFT JOIN `table_news` n
ON (n.`id_news` = nl.`id_news`)
LEFT JOIN `table_correspondancecategorie` cc
ON (n.`id_news` = cc.`news`)
WHERE 1=1
AND
EXISTS (
SELECT 1
FROM `table_categorie` pc
JOIN `table_categorie_group` pcg
ON (pc.`id_categorie` = pcg.`id_categorie` AND pcg.`id_group` = 1)
WHERE cc.`categorie` = pc.`id_categorie`
)
AND n.`id_shop` = 1
AND nl.`id_lang` = 1
AND n.`actif` = 1
AND nl.`actif_langue` = 1
AND TIMESTAMP(n.`date`) <= '2017-08-23 11:04:09'
ORDER BY n.`date` desc
LIMIT 240, 10; |
Partager