Pages
-
Recent Posts
Archives
Category Archives: SQL
Getting the next n birthdays from a table in SQL
If we have a table with a basic structure like this: ———- person ———- person_id name dob … ———- Let’s run a query with the results sorted by order of upcoming birthdays: SELECT *, IF(MONTH(`dob`) < MONTH(NOW()) || (MONTH(`dob`) = … Continue reading →