Do You Know How to Write This SELECT Statement . . . ?

Discussion in 'Databases' started by Masterful, Sep 15, 2008.

  1. #1
    Whenever I add a new row of data to my database, I give it an expiration date (e.g., 2008-10-01).

    How do I select all rows due to expire in the next 3 days (today, tomorrow or the day after)?
     
    Masterful, Sep 15, 2008 IP
  2. CreativeClans

    CreativeClans Peon

    Messages:
    128
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    SELECT *
    FROM tablename
    WHERE expdate >= CURDATE()
    AND   expdate <= ADDDATE(CURDATE(), 2)
    
    Code (markup):
     
    CreativeClans, Sep 16, 2008 IP