1

I would like run an INSERT statement to update a MySQL table with two values: The first value is pulled from a SELECT statement on a single column in another table. The second value I would like to be static.

Here is a generic example of what I'm working with:

INSERT INTO employee(id,salary) SELECT id,salary FROM contractor;

However, I would like salary to be a fixed, static value. We'll use '50000' as that static value. So here is a rough version of what I think the final statement would look like:

INSERT INTO employee(id,salary) SELECT id FROM contractor, '50000';

Am I on the right path with this? Thanks.

1 Answer 1

3

You can do this way (the resulting value must be in select clause)

INSERT INTO employee(id,salary) SELECT id, 5000 FROM contractor;
Sign up to request clarification or add additional context in comments.

Comments

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.