Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012
    Posts
    1

    Unanswered: Insert into select AND values

    Just wondering if there is a way to combine insert into using select & values. I have a table with say 5 columns. I want to insert into 4 columns from another table from but for 1 column insert manually (say 55 for all the rows in that column).

    Is there a way to do this apart from using:
    INSERT INTO table1 (c1,c2,c3,c4)
    SELECT a1,a2,a3,a4 FROM table2

    and then UPDATE c5 in table 1.

    but is there a way to do this in 1 query (maybe using Values)?

    thanks heaps,

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    INSERT 
      INTO table1 
         ( c1,c2,c3,c4,c5 ) 
    SELECT a1,a2,a3,a4,55
      FROM table2
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

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
  •