Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to delete rows from a table using inner join with multiple table but i am getting error every time.
The query is :-
Delete  from FilteredEqDump as A
  inner join AssociateProductionDetail  on 
A.EmployeeCode=AssociateProductionDetail.EmployeeCode and    
A.CountyTaskFlag=AssociateProductionDetail.CountyTaskFlag and  
A.ProjectName=AssociateProductionDetail.ProjectName 
inner join NonProdWorkType  on 
A.EmployeeCode=NonProdWorkType.EmployeeCode and    
A.Employeename=NonProdWorkType.EmployeeName and    
A.CountytaskFlag=NonProdWorkType.CountyTaskFlag and    
A.CountyGroupname=NonProdWorkType.CountyGroupName and    
A.ProjectName=NonProdWorkType.ProjectName
where       
   A.WorkType ='NON PRODUCTION' 


I am getting error as "Incorrect syntax near the keyword 'inner'." at line Number 2.
Please help me that what the mistake i m doing and if possible please correct it and share me the query.
Posted

I hope your FilteredEqDump table has an ID column...
Then use a sub-query to get the IDs and use those IDs in the WHERE clause:
SQL
Delete  from FilteredEqDump 
Where FilteredEqDump.ID IN 
(SELECT FilteredEqDump.ID 
FROM FilteredEqDump
inner join AssociateProductionDetail  on
FilteredEqDump.EmployeeCode=AssociateProductionDetail.EmployeeCode and
FilteredEqDump.CountyTaskFlag=AssociateProductionDetail.CountyTaskFlag and
FilteredEqDump.ProjectName=AssociateProductionDetail.ProjectName
inner join NonProdWorkType  on
FilteredEqDump.EmployeeCode=NonProdWorkType.EmployeeCode and
FilteredEqDump.Employeename=NonProdWorkType.EmployeeName and
FilteredEqDump.CountytaskFlag=NonProdWorkType.CountyTaskFlag and
FilteredEqDump.CountyGroupname=NonProdWorkType.CountyGroupName and
FilteredEqDump.ProjectName=NonProdWorkType.ProjectName
where FilteredEqDump.WorkType ='NON PRODUCTION')
 
Share this answer
 
Maybe this link will help you.....

http://www.sqlservercentral.com/Forums/Topic493913-338-1.aspx[^]

good luck! :)
 
Share this answer
 
Delete FilteredEqDump  from FilteredEqDump as A
  inner join AssociateProductionDetail  on 
A.EmployeeCode=AssociateProductionDetail.EmployeeCode and    
A.CountyTaskFlag=AssociateProductionDetail.CountyTaskFlag and  
A.ProjectName=AssociateProductionDetail.ProjectName 
inner join NonProdWorkType  on 
A.EmployeeCode=NonProdWorkType.EmployeeCode and    
A.Employeename=NonProdWorkType.EmployeeName and    
A.CountytaskFlag=NonProdWorkType.CountyTaskFlag and    
A.CountyGroupname=NonProdWorkType.CountyGroupName and    
A.ProjectName=NonProdWorkType.ProjectName
where       
   A.WorkType ='NON PRODUCTION' 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900