PHP Select from MySQL where date field is 7 days in the future

后端 未结 6 1564
无人及你
无人及你 2021-01-28 12:30

I have an automatic checker that checks for domains that are going to expire within the next 7 days and it sends and email to the customer.

Im using this SQL Query:

6条回答
  •  孤城傲影
    2021-01-28 13:20

    You have to use parentheses with your and/or conditions

    SELECT * from domain_names 
    where (status = '' or status = 'valid')
    and expiry_date = curdate() + INTERVAL 7 DAY
    

    or use in in your case

    SELECT * from domain_names 
    where status in ('', 'valid')
    and expiry_date = curdate() + INTERVAL 7 DAY
    

提交回复
热议问题