Hi,
I'm trying to insert into my headcount table new persons with the following code.
The month information is coming from another linked table. Now each time I run the code it doubles the amount of records appended. First time it adds one person, second time the same person twice and third time four times. Is there a way to fix the SQL so that it generates only one line to the table?
I'm trying to insert into my headcount table new persons with the following code.
Code:
INSERT INTO HeadCountTbl (HeadCount, EmpID, Month_ID )
SELECT 1, HeadCountTbl.EmpID, HeadCountTbl.Month_ID
FROM MonthTbl INNER JOIN HeadCountTbl ON MonthTbl.ID = HeadCountTbl.Month_ID
WHERE (((HeadCountTbl.EmpID)=123) AND ((MonthTbl.Month)=201905));
The month information is coming from another linked table. Now each time I run the code it doubles the amount of records appended. First time it adds one person, second time the same person twice and third time four times. Is there a way to fix the SQL so that it generates only one line to the table?