0

Its like this. I have a proyects table and I want to create an entry into a second (task_groups) table for each proyect that I have.

Like this:

SELECT name,keyid FROM proyects;

Now for each result in the above query I want to do something like this.

INSERT INTO task_groups (name,proyect,advance) VALUES ('Task for proyect proyect.name', 'proyect.keyid','0')

Where proyect.name and proyect.keyid are the values for each row resulting in the first query.

Is it possible to write a query to get what I want?

1 Answer 1

1

You can put a SELECT query in place of the VALUES clause:

INSERT INTO task_groups (name, proyect, advance)
SELECT CONCAT('Task for proyect ', name), keyid, '0'
FROM proyects
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.