Answer the question
In order to leave comments, you need to log in
How to select data from mysql table by multiple dates?
I inherited a site on DLE and there is a self-written plugin that allows you to display episodes for the series. Among other things, there is such a terrible request.
(SELECT `t1`.`season`, `t1`.`episode`, `t1`.`name_orig`, `t1`.`name_rus`, `t1`.`date` AS `release`, `t2`.`id`, `t2`.`alt_name`, `t2`.`date`, `t2`.`category`
FROM `" . PREFIX . "_episodes` AS `t1`
LEFT OUTER JOIN `" . PREFIX . "_post` AS `t2` ON `t2`.`id` = `t1`.`post_id`
WHERE `t1`.`date` <= NOW()
ORDER BY `season`, `episode` DESC
" . $limitSQL . ")
UNION
(SELECT `t1`.`season`, `t1`.`episode`, `t1`.`name_orig`, `t1`.`name_rus`, `t1`.`date` AS `release`, `t2`.`id`, `t2`.`alt_name`, `t2`.`date`, `t2`.`category`
FROM `" . PREFIX . "_episodes` AS `t1`
LEFT OUTER JOIN `" . PREFIX . "_post` AS `t2` ON `t2`.`id` = `t1`.`post_id`
WHERE `t1`.`date` > NOW()
ORDER BY `season`, `episode`
LIMIT 1)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question