SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    copying table into another

    Hello

    I have two tables.

    Pending (id, uid, data)
    Approved (id, uid, data)

    When data is submitted it is inserted into the pending table. Once approved I want the data to be transferred into the approved table.

  2. #2
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can write a trigger
    like

    CREATE TRIGGER myTrigger
    AFTER INSERT ON PENDING
    FOR EACH ROW
    BEGIN
    CHK HERE APPROVED CONDIN

    IF APPROVED
    INSERT INTO Approved (id, uid, data) values(id, uid, data)

    END

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,263
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Jaynesh View Post
    When data is submitted it is inserted into the pending table. Once approved I want the data to be transferred into the approved table.
    you should really have only one table, with a status column

    then instead of "transferring" rows from one table to another, you simply update the status
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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