CREATE TABLE `birthday` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`date` datetime DEFAULT '0000-00-00 00:00:00',
`name` tinytext,
`photo` tinytext,
`description` tinytext,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=241 DEFAULT CHARSET=cp1251;
(SELECT *
FROM `birthday`
WHERE MONTH(`date`) > MONTH(CURDATE())
OR (MONTH(`date`) = MONTH(CURDATE())
AND DAYOFMONTH(`date`) = DAYOFMONTH(CURDATE()))
ORDER BY MONTH(`date`), DAYOFMONTH(`date`)
LIMIT 3)
UNION (SELECT *
FROM `birthday`
WHERE MONTH(`date`) = MONTH(CURDATE())
AND DAYOFMONTH(`date`) = DAYOFMONTH(CURDATE()))
UNION (SELECT *
FROM `birthday`
WHERE MONTH(`date`) < MONTH(CURDATE())
OR (MONTH(`date`) = MONTH(CURDATE())
AND DAYOFMONTH(`date`) < DAYOFMONTH(CURDATE()))
ORDER BY MONTH(`date`) DESC, DAYOFMONTH(`date`) DESC
LIMIT 3)