SQL INSERT query malfunctioned

I have a SQL query which checks for duplicated records in a table, and it malfunctioned after I've added some columns to specific tables.Below is my table structure: \[code\]**user1** tableUserIDNameLoggedInUser -> each record's owner identified by LoggedInUser**UserCheck** tableUserIDNameIssueLoggedInUser\[/code\]My SQL query: \[code\]string LoggedInUser = (User.Identity.Name);nonqueryCommand.CommandText ="INSERT INTO UserCheck(UserID, Name, Issue , LoggedInUser) SELECT user1.UserID, user1.Name, 'DUPLICATED user found in User1 List' , '" + LoggedInUser + "' FROM UserDB AS user1 GROUP BY user1.UserID, user1.Name HAVING COUNT(*) > 1";\[/code\]//EDIT:In conclusion, my problem is that user1 table contains records from different users.And my check should only grep those rows whose name is \[code\]LoggedInUser\[/code\]==\[code\]User.Identity.Name\[/code\], which is the name of the user using the sysem.Now my INSERT query is grepping all the rows from user1 table instead of checking \[code\]LoggedInUser\[/code\] for each row if it matches \[code\]User.Identity.Name\[/code\].How should I modify my Insert statement?
 
Back
Top