My largest MySQL SELECT statement.
Dec 31
2009
2009
Comments Off
SELECT id, name, fullname, birth1, death1, deathplace, is_divorced, wedding1, ann_name, MONTH( birth1 ) AS bday_month, DAYOFMONTH( birth1 ) AS bday_day, YEAR( birth1 ) AS event_year, DATE_FORMAT( birth1, '%m %d' ) AS event_date, DATE_FORMAT( birth1, '%Y-%m-%d' ) AS event_date_comp, DATE_FORMAT( birth1, '%b %d' ) AS event_date_display FROM armer_individuals WHERE ( MONTH( birth1 ) > '$c_month' ) OR ( ( MONTH( birth1 ) = '$c_month' ) AND ( DAYOFMONTH( birth1 ) > '$c_day' ) ) ORDER BY event_date ) UNION ( SELECT id, name, fullname, birth1, death1, deathplace, is_divorced, wedding1, ann_name, MONTH( wedding1 ) AS ann_month, DAYOFMONTH( wedding1 ) AS ann_day, YEAR( wedding1 ) AS ann_year, DATE_FORMAT( wedding1, '%m %d' ) AS event_date, DATE_FORMAT( wedding1, '%Y-%m-%d' ) AS event_date_comp, DATE_FORMAT( wedding1, '%b %d' ) AS event_date_display FROM armer_individuals WHERE ( ( MONTH( wedding1 ) > '$c_month' ) OR ( ( MONTH( wedding1 ) = '$c_month' ) AND ( DAYOFMONTH( wedding1 ) > '$c_day' ) ) ) AND ( is_divorced <> 'yes' ) AND ( YEAR( death1 ) = '0' ) ORDER BY event_date ) ORDER BY event_date LIMIT 5 " |
—————————————————–
And here is the result, happen to have no anniversaries in the nest 5 events.
