Reputation: 5556
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?
Upvotes: 0
Views: 33
Reputation: 780798
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
Upvotes: 1