mysql - Query users with no activity for 3 days -


i have system in users can send each other comments. want find users haven't sent comments 3 days. also, run on daily cron , want them receive email once every 3 days after last comment, i'm trying latest comment between 3 , 4 days.

here's have:

$sql = "select u.firstname, u.email          user u         left join comment c on u.id=c.sender         (date(c.date) between ( curdate() - interval 4 day )                , ( curdate() - interval 3 day ))                , u.disabled=0          group u.id"; 

use date_sub subtracts interval from provided date

try this

$sql = "select u.firstname, u.email          user u         left join comment c on u.id=c.sender         (date(c.date) between date_sub(now(),interval 4 day)                  , date_sub(now(),interval 3 day)                , u.disabled=0          group u.id" 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -