3

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!

1 Answer 1

10

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
Sign up to request clarification or add additional context in comments.

1 Comment

i've edited my question, could you answer the edited version again please?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.