此查询选择“用户过期”行“B1month”的所有用户。

$oneMonthUsersData = mysql_query("SELECT username,email FROM user WHERE DATEDIFF(NOW(),date_created) > 30 AND user_expire = 'B1month'");
while ($oneMonthUsers = @mysql_fetch_array($oneMonthUsersData)) {
    $deletedUsers = $deletedUsers.",".$oneMonthUsers['username'];
    $deletedUsersEmails[] = $oneMonthUsers['email'];
}

如果我希望同一个查询同时选择“user_expire”行“C1month”和“B1month”行的所有用户,应该如何格式化语法?

最佳答案

您是否尝试过以下查询:

SELECT username,email FROM user WHERE DATEDIFF(NOW(),date_created) > 30 AND (user_expire = 'B1month' OR user_expire = 'C1month')

08-18 01:10