我有一个以下结构的数据库:
用户
userid (Primary Key)
username
分组
groupid (PK)
groupName
用户组
userid (Foreign Key)
groupid (Foreign Key)
当用户第一次登录时,我希望将其信息添加到用户表中。因此,如果实现以下逻辑:
if (//users table does not contain username)
{
INSERT INTO users VALUES (username);
}
我该如何使用SQL Server/C#智能地实现这个?