SELECT `tn_post_category_relation`.`post_id`, `tn_posts`.`title`, `tn_posts`.`description`, `tn_posts`.`post_datetime`, date(tn_posts.post_datetime) ndate, `tn_images`.`image_name` AS `image_name`, `tn_posts`.`excerpt`, `tn_posts`.`slug`, `tn_post_category_relation`.`category_id`, `tn_category`.`category_name`, `tn_category`.`slug` as `category_slug`, `tn_category`.`color_code` AS `category_color` FROM `tn_posts` JOIN `tn_post_category_relation` ON `tn_post_category_relation`.`post_id` = `tn_posts`.`id` JOIN `tn_category` ON `tn_category`.`id` = `tn_post_category_relation`.`category_id` LEFT JOIN `tn_post_images` ON `tn_post_images`.`post_id` = `tn_posts`.`id` AND `is_featured`=1 LEFT JOIN `tn_images` ON `tn_images`.`id` = `tn_post_images`.`image_id` LEFT JOIN `tn_post_author_relation` ON `tn_post_author_relation`.`post_id`=`tn_posts`.`id` LEFT JOIN `tn_users` ON `tn_users`.`id`=`tn_posts`.`created_by` LEFT JOIN `tn_authers` ON `tn_authers`.`id` = `tn_post_author_relation`.`author_id` LEFT JOIN `tn_post_category_sequence` ON `tn_post_category_sequence`.`post_id` = `tn_posts`.`id` LEFT JOIN `tn_post_meta` as `t1` ON `t1`.`post_id` = `tn_posts`.`id` AND `t1`.`meta_key`='show_video_icon' WHERE `tn_posts`.`publish_status` = 1 AND `tn_posts`.`post_type` = 1 AND `tn_category`.`id` = '39' GROUP BY `tn_post_category_relation`.`post_id` ORDER BY `tn_posts`.`post_datetime` DESC, `tn_posts`.`id` DESC LIMIT 12