For anyone who comes across this:
another way this can be done is:
SELECT TIMESTAMPDIFF(YEAR, date_of_birth, CURDATE()) AS difference FROM student
For differences in months, replace YEAR
with MONTH
, and for days replace YEAR
with DAY
Hope that helps!
More Related Contents:
- SQL split values to multiple rows
- How do I escape reserved words used as column names? MySQL/Create Table
- How to store multiple options in a single table?
- How to populate a table with a range of dates?
- Get the new record primary key ID from MySQL insert query?
- What is the opposite of GROUP_CONCAT in MySQL?
- How to Perform an UPSERT so that I can use both new and old values in update part
- brew install mysql on macOS
- TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT maximum storage sizes
- MySQL: selecting rows where a column is null
- How do I check to see if a value is an integer in MySQL?
- Convert timestamp to date in MySQL query
- Update a column value, replacing part of a string
- Store image to database blob; retrieve from db into Picturebox
- MySQL trigger On Insert/Update events
- MySQL combine two columns into one column
- MySQL Insert Into from one Database in another
- How can I change MariaDB to MySQL in XAMPP?
- MySQL: LIMIT by a percentage of the amount of records?
- How to remove all MySQL tables from the command-line without DROP database permissions? [duplicate]
- MySQL multiple columns in IN clause
- MySQL Stored Procedures not working with SELECT (basic question)
- Sum results of a few queries and then find top 5 in SQL
- ERROR 1148: The used command is not allowed with this MySQL version
- Too many auto increments with ON DUPLICATE KEY UPDATE
- MySQL OPTIMIZE all tables?
- What’s mysql’s “BETWEEN” performance over..?
- Deleting a row based on the max value
- mysql double-quoted table names
- MySQL giving “read ECONNRESET” error after idle time on node.js server