SQL查询为新表中的另一个表的所有id插入相同的记录

时间:2022-08-11 19:19:48

I'm having two tables: notificattins and users

我有两张桌子:notificattins和用户

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

我想在users表中为每个记录插入一条记录。

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

实际上我想为每个用户添加一个通知。

can anyone help me?

谁能帮我?

1 个解决方案

#1


1  

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

#1


1  

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