www.webdeveloper.com
Results 1 to 6 of 6

Thread: Is it possible to dynamically remove data from a table?

  1. #1
    Join Date
    Jul 2008
    Location
    Bristol
    Posts
    77

    Is it possible to dynamically remove data from a table?

    Hello everyone

    I'd like to know if it is possible to be able to remove dormant data from a table dynamically? I have a table in my database which is for reserved tickets that are on sale on a site, but they will only be needed in there for about 10 minutes (which is the reserve time before they go back on sale) and I'd like to be able to get those entries deleted as they would no longer be needed and would just take up space in the table.

    The time will be logged in the table using the NOW() command plus 10 minutes, so I'm assuming that there is a way to query the database to check for expired times and then delete them?

    If anyone knows of how and if this is possible, I would be grateful for any help.

    Thanks
    Michael

  2. #2
    Join Date
    Oct 2009
    Posts
    658
    Code:
    SELECT * FROM Table WHERE your_date_field <= NOW()
    Good Luck

    Santos Systems

  3. #3
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227
    If you are using MSSQL Server...

    SELECT * FROM Table WHERE your_date_field <= '" & NOW() & "'

  4. #4
    Join Date
    Oct 2009
    Posts
    658
    Quote Originally Posted by yamaharuss View Post
    If you are using MSSQL Server...

    SELECT * FROM Table WHERE your_date_field <= '" & NOW() & "'
    That's for ASP if I'm not mistaken. Fr MSSQL it should be

    Code:
    SELECT * FROM Table WHERE your_date_field <= GETDATE()
    Good Luck

    Santos Systems

  5. #5
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227
    I was assuming the query was running from a web page. If so, and using MSSQL, the date field required single quotes.

  6. #6
    Join Date
    Jul 2008
    Location
    Bristol
    Posts
    77
    Thanks for your help The NOW() did the trick.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles