Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    insert with select troubles.

    Yay!! I got it with singel quotes. Thought I had previously tried that.

    When inserting to an archive table with data selected from a 'live' table, I want also to input to the archived table, the name of the person who did it ~ $admin

    I can't seem to work out how to get the $admin var into the insert. I seek your guidance.

    Code:
    INSERT INTO files_archived 
                                    ( business_id
                                    , content_category
                                    , file_name
                                    , file_text
                                    , live_from
                                    , when_archived
                                    , archived_by
                                    )
                                  SELECT
                                   business_id 
                                  , content_category
                                  , file_name
                                  , file_text
                                  , live_from
                                  , CURRENT_TIMESTAMP
                                  , "$admin"
                               FROM files as f
                              WHERE f.business_id = ?
                                AND f.content_category = ?
                                AND f.file_name = ?
                                AND f.live_from = ?
                                and archived_by = ?
    If you haven't time can you maybe supply me with a search term?

    bazz
    Last edited by bazz; 03-20-2010 at 03:14 AM.
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link


 

Posting Permissions

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