我想在节点js中创建通知应用程序,我只是在SQL Server中使用这三个表创建了一个数据库:
tbluser
user_id
user_name
tbluser_notification
user_id
noti_id
read
tblnotification
noti_id
noti_title
noti_mesg
noti_create
noti_sender_id
我的问题是:每当我向tblnotification
插入通知时,我都希望将每个用户的记录插入tbluser_notification
。
答案 0 :(得分:0)
插入触发器后创建
CREATE TRIGGER [dbo].[trgtblnotificationInsert]
ON [dbo].[tblnotification]
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO tbluser_notification (user_id, noti_id, notificationread)
SELECT tbluser.user_id, inserted.noti_id, 0
FROM tbluser
CROSS JOIN inserted
END
请注意:我已将列名'read'更改为'notificationread',因为read是保留字。