Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Query to select between 2 dates

Tags:

php

mysql

I have a Table 'Notification_details' where I query to obtain the unique records with the following MySQL query

enter image description here

select userid, max(notification_date) as notification_date from notification_details group by userid order by notification_date asc

Which gives the result, where the userid is unique and the notification_date is the latest( max). Now, I would like to extend the MySQL command to query between 2 dates of the result I have obtained :

enter image description here

Any idea, how to extend the above MySQL command ?

like image 705
Kiran Avatar asked Jun 07 '26 01:06

Kiran


1 Answers

If I didn't missunderstand you:

SELECT alias.* 
FROM (select userid, max(notification_date) as notification_date from notification_details group by userid order by notification_date asc) alias
WHERE alias.notification_date BETWEEN DATE1 AND DATE2
like image 63
Leandro Bardelli Avatar answered Jun 08 '26 14:06

Leandro Bardelli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!