Duplicate entry '5126' for key 'group_key'
CREATE TEMPORARY TABLE news_db AS ( select m.*, mv.* from (SELECT pid as temp_matching_id , MAX(IF(field = 'pid', value, NULL)) AS 'pid' , MAX(IF(field = 'date', value, NULL)) AS 'date' , MAX(IF(field = 'programmes', value, NULL)) AS 'programmes' , MAX(IF(field = 'diploma', value, NULL)) AS 'diploma' , MAX(IF(field = 'type', value, NULL)) AS 'type' , MAX(IF(field = 'archive_name', value, NULL)) AS 'archive_name' , MAX(IF(field = 'post_by_tc', value, NULL)) AS 'post_by_tc' , MAX(IF(field = 'post_by_en', value, NULL)) AS 'post_by_en' , MAX(IF(field = 'title_tc', value, NULL)) AS 'title_tc' , MAX(IF(field = 'title_en', value, NULL)) AS 'title_en' , MAX(IF(field = 'news_tc', value, NULL)) AS 'news_tc' , MAX(IF(field = 'news_en', value, NULL)) AS 'news_en' , MAX(IF(field = 'banner_tc', value, NULL)) AS 'banner_tc' , MAX(IF(field = 'banner_en', value, NULL)) AS 'banner_en' , MAX(IF(field = 'image_tc', value, NULL)) AS 'image_tc' , MAX(IF(field = 'image_en', value, NULL)) AS 'image_en' , MAX(IF(field = 'sub_tc', value, NULL)) AS 'sub_tc' , MAX(IF(field = 'sub_en', value, NULL)) AS 'sub_en' , MAX(IF(field = 'form', value, NULL)) AS 'form' , MAX(IF(field = 'meta_keywords', value, NULL)) AS 'meta_keywords' , MAX(IF(field = 'meta_desc', value, NULL)) AS 'meta_desc' FROM main_value_db group by pid ) as mv left join main_db m on m.id = mv.temp_matching_id where m.module = 'news' )