19th February, 2016 Merge topics end with s to topics without s


select * from topic_merge order by create_date desc limit 100;
select articles, topic.* from topic where title like'Italians';

//without s query
SELECT
    b.topic_id,
    b.title as ' merged titles',   
    a.topic_id,
  a.title AS 'parent title',
  b.articles as 'merged articles',
  a.articles as 'parent article'
 
FROM
    topic a,
    topic b
WHERE
    b.articles < 20 AND b.articles > 0
        AND  a.articles>0
        AND (b.title LIKE '%s')
        AND a.title = SUBSTRING(b.title,
        1,
        CHAR_LENGTH(b.title) - 1)
        AND (a.articles DIV b.articles >= 3)
LIMIT 100000;



select create_date, title from topic where articles <3 and articles > 0 order by create_date asc limit 100000;
//with s query
SELECT
    b.topic_id,
    a.topic_id,
    b.title AS 'title to be merged',
    b.articles,
    b.create_date,
    a.title,
    a.articles
FROM
    topic a,
    topic b
WHERE
    a.articles < 50 AND a.articles > 0
        AND b.articles > 0
        AND (a.title LIKE '%s')
        AND b.title = SUBSTRING(a.title,
        1,
        CHAR_LENGTH(a.title) - 1)
        AND (a.articles DIV b.articles >= 3)
LIMIT 10000;

Comments