-3
I need to make a query in MYSQL database to verify if a user is of age based on their date of birth compared to the current date.
If yes the user should be deleted from the database.
-3
I need to make a query in MYSQL database to verify if a user is of age based on their date of birth compared to the current date.
If yes the user should be deleted from the database.
2
First, an example of how to get a date type value in mysql.
SELECT STR_TO_DATE('2019-04-15', '%Y-%m-%d');
Example of getting the difference between the dates
SELECT TIMESTAMPDIFF(YEAR,'2002-05-01','2001-01-01');
As for DELETE, you can do so:
DELETE FROM suaTabela WHERE TIMESTAMPDIFF(YEAR,'2002-05-01',CURDATE()) >=18;
It is a good north. Good studies!
kkk I would have done the process in the back-end language
Browser other questions tagged mysql mysqli
You are not signed in. Login or sign up in order to post.
Where is your doubt? What have you tried so far?
– Filipe L. Constante
The doubt is that I do not know how to compare the current date with the date of birth to check if you are 18 or not rsrs
– Frederico Moreira
I have no idea where to start
– Frederico Moreira
So I suggest we start by looking at search history here of the same site, which has several questions dealing with the difference between dates in SQL and with this you will be able to at least define a starting point.
– Woss