user1123513
user1123513

Reputation: 25

MySQL - Taking data from one column in a table and inserting it into another table

I have two tables users(id, username, password) and user_badges(user_id, badge_id, badge_slot)

I would like to insert the data (id from user table, FBB, 0) for every row in the users table.

How can I do this?

Thanks!

Upvotes: 0

Views: 411

Answers (1)

Sergio Tulentsev
Sergio Tulentsev

Reputation: 230296

You want this?

INSERT INTO user_badges(user_id, badge_id, badge_slot)
SELECT id, 'FBB', 0
  FROM users;

Upvotes: 5

Related Questions