I am trying to return a list of email addresses that expire 30 days from now. To do that I need to look for users from 335 days ago since all accounts expire 365 days after setup and I only log the setup date in MySQL as a timestamp. Here is the PHP statement I am using which is not returning a list for me. Any ideas:
$sql2 = "SELECT * FROM `users` WHERE `TYPE` > 0 AND `ID` > 0 AND `UPDATED_DATE` = DATE_SUB(NOW(),INTERVAL 335 DAY)";
$result = $conn->query($sql2);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "email: " . $row["EMAIL"]. $row["ID"]."<br>";
}
} else {
echo "0 results";
}
UPDATED_DATE >= DATE_SUB(NOW(),INTERVAL 335 DAY)?mqsqlquery withoutphpand see result if there are result so the isseu withphpcode if there are not then the error withmysqlquery<=since you want accounts older than that date.updated_date? is it aDATEorDATETIME?mysqlwrite the table struct the most simple way to run the codeshow create table table_namethe result gonna be likeCREATE TABLE `test` ( `id` int(30) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(10) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`), UNIQUE KEY `id_2` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1000001 DEFAULT CHARSET=utf8copy it to the question`