views:

44

answers:

1

Okay, This one is pretty simmilar to my last one, but I don't get it...!

I am trying the following:

Insert into table b
  (Select column_1 from table_a where ID = 1),
  (Select column_2 from table_a where ID = 1),
  0,
  (Select column_3 from table_a where ID = 1);

But I always get a syntax-error...! I think it's quite logical what I'm trying to do.

Greetz from Germany and thx for your answers!

+6  A: 

Very close - use:

INSERT INTO TABLE_B
SELECT column_1, column_2, column_3 
  FROM TABLE_A
 WHERE id = 1

..assuming there are only three columns in TABLE_B. Otherwise, specify the columns being inserted into:

INSERT INTO TABLE_B
  (column_1, column_2, column_3)
SELECT column_1, column_2, column_3 
  FROM TABLE_A
 WHERE id = 1

And, if need be--you can use statically defined values as well:

INSERT INTO TABLE_B
  (column_1, column_2, column_3, column_4)
SELECT column_1, column_2, 0, column_3 
  FROM TABLE_A
 WHERE id = 1
OMG Ponies
i've edited my question, could you answer the edited version again please?
Husky110
@Husky110: See update.
OMG Ponies