Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.


Results 1 to 2 of 2

Thread: Insert then delete Data

  1. #1

    Insert then delete Data

    i have a form that inserts the form data into a table (pending_tbl) and all pending are outputted in a list with accept button, when you click the accept button it populates a form with the details for viewing, if all is ok you click submit and it inserts this into another table (members_tbl) this works but what i need it to do is once it inserts the data into members_tbl it deletes it from pending_tbl.

    Who is this done?

  2. #2
    just run a DELETE statement. so something like:
    DELETE FROM pending_tbl WHERE pending_id IN ( 1, 2, 3, 4 )
    so that would delete everything in pending_tbl where the pending_id (assuming that was your id column) is 1, 2, 3, or 4.

    if you want it more advanced, i would probably do something like this for each record:
    INSERT INTO members_tbl
    FROM pending_tbl
    WHERE pending_tbl.pending_id = 1;
    UPDATE pending_tbl
    SET members_id = LAST_INSERT_ID(),
    members_date = NOW()
    WHERE pending_id = 1;
    so that would require you to have 2 additional columns in pending_tbl: members_id and members_date. members_id would reference the id number assigned to the transferred record. members_date would just track what day the transfer was made.

    i would probably have the records in pending expire after like 2 days post-transfer. that way, if there are any problems you can go back to the pending table and reconcile the issues. but you're not keeping the additional data around for too long.

    clearly then, you would only be able to approve pending_id numbers where the members_id IS NULL.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012