SELECT `p`.`name` AS `pub_name`, `c`.`media_url` AS `cover_url`
FROM (
SELECT DISTINCT `publication_id`
FROM `tbl_publication_media`
WHERE `media_type` = 2
) AS `v`
JOIN `tbl_publication` AS `p`
ON `p`.`id` = `v`.`publication_id`
LEFT JOIN `tbl_publication_media` AS `c`
ON `c`.`publication_id` = `p`.`id` AND `c`.`media_type` = 4
INSERT INTO `table` (`id`, `date`, `message`)
(
SELECT `t`.`id`, `t`.`date`, `t`.`message`
FROM (SELECT :id AS `id`, :date AS `date`, :message AS `message`) AS `t`
JOIN (SELECT MAX(`date`) AS `date` FROM `table`) AS `m`
WHERE `t`.`date` > `m`.`date`
)
Mode 1:
First day of week: Monday
Range: 0-53
Week 1 is the first week … with 4 or more days this year
For mode values with a meaning of “with 4 or more days this year,” weeks are numbered according to ISO 8601:1988:
- If the week containing January 1 has 4 or more days in the new year, it is week 1.
- Otherwise, it is the last week of the previous year, and the next week is week 1.