Amin Sajedi
Amin Sajedi

Reputation: 135

SQL query to insert the same record for all the ids of another table in a new table

I'm having two tables: notificattins and users

I want to insert one record into the notifications table for every record of the users table.

in fact i want to add one notification for every user to receive.

can anyone help me?

Upvotes: 1

Views: 411

Answers (1)

juergen d
juergen d

Reputation: 204756

You did not specify your table structure but generally you can do this

insert into notifications (some_column, other_column)
select username, other_column
from users

Upvotes: 1

Related Questions