There are tables Subjects (SubjectId, Name, keys) and KeyWords (Id, Word (index)) many-to-many relation. KeyWords has a Word field that has a unique attribute. I use EF c MS SQL. I do not know how to check whether there are already such keywords when adding to the KeyWords table in the Word field. Is it possible to do this without additional requests for checking the existence of each Word in KeyWords?
1 answer
I would suggest declaring a temporary table variable, inserting keywords into it.
Declare @temp_keywords table ( AKeyword <type(length>); Insert into @temp_keywords (AKeyword) values ('keyword1'); Insert into @temp_keywords (AKeyword) values ('keyword2'); .. Insert into @temp_keywords (AKeyword) values ('keywordN'); Select AKeyword as word Into Keywords FROM @temp_keywords Where @temp_keywords.AKeyword not in ( select word from keywords where Id=ASubjectId) |