SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2002
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    inserting a column without altering table

    Here's the situation, I am loading data from multiple tables into one master table. Everything is mapped fine and working (different table column layouts, etc)

    Now, what I would like to do is something like this:

    INSERT INTO db.foo (DATA, SKU, ETC)
    SELECT "A Specific Value Here", sku, etc from db.bar
    where "A Specific Value Here" is NOT a column in db.bar, but a value I enter. Is there anyway of doing this without going through all my tables and entering this new column + values ? (the "A Specific Value Here" will be one number, the same for all rows being inserted from db.bar, but different for other INSERT statements gathering data from other db.tables)

    Thank You!

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    697
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    INSERT INTO db.foo (DATA, SKU, ETC)
    SELECT 'A Specific Value Here', sku, etc from db.bar
    If the DATA column is numeric, remove the quotes.


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
  •