Reputation: 2736
SO I have a tablr users
table whose structure is
id | name | email | password | role_id
and it has 100 entries in it.
I have a couriers
table whose structure is
id | user_id | so on.
I would like to populate the couriers
table with the value in the users
table that has the role_id of 3.
So I have 40 couriers and I want them to be inserted into the couriers
table.
Upvotes: 0
Views: 30
Reputation: 967
You can use the syntax:
INSERT INTO couriers (column1, column2, column3, ...)
SELECT column1, column2, column3, ...
FROM users
WHERE condition;
Upvotes: 1