210
Views
8
Comments
Solved
Error in using SQL inner join delete
Question

Hi Experts,


I have been trying to use inner join to execute delete function, however i have a error.

where did my SQL command goes wrong, please see below screenshot.

thanks in advance.




2020-06-17 07-09-57
Ja
Solution

Hi,

Thanks for your input, however i ended up using this suggested syntax

2020-06-10 05-06-30
shehroze khan

Hello Ja

There is no screen shot attached, can you attach your screen shot and update it again.

check if you are using "output" in that sql query because output is mandatory.

Thanks

shehroze khan

2026-02-26 06-29-24
Rahul
 
MVP

Hi JA,

see here for delete query with join.

https://www.javatpoint.com/sql-delete-join

https://blog.sqlauthority.com/2013/05/03/sql-server-delete-from-select-statement-using-join-in-delete-statement-multiple-tables-in-delete-statement/


DELETE [target table

FROM    [table1]         

 INNER JOIN [table2]  

ON [table1.[joining column] = [table2].[joining column]  

WHERE   [condition] 


and use for output structure . delete query return nothing but its mendatory to add output.


Regards

Rahul Sahu

2020-06-17 07-09-57
Ja

Rahul Sahu wrote:

Hi JA,

see here for delete query with join.

https://www.javatpoint.com/sql-delete-join

https://blog.sqlauthority.com/2013/05/03/sql-server-delete-from-select-statement-using-join-in-delete-statement-multiple-tables-in-delete-statement/


DELETE [target table

FROM    [table1]         

 INNER JOIN [table2]  

ON [table1.[joining column] = [table2].[joining column]  

WHERE   [condition] 


and use for output structure . delete query return nothing but its mendatory to add output.


Regards

Rahul Sahu

Hi Rahul,


That i already tried that syntax but i encountered the same problem so i try to isolate using a single table deletion and it is working fine.

My problem is where when i used the inner join

see below screenshot




2022-02-07 08-52-30
Pranav Pandey

Hi Ja,

your statement is wrong . Please declare the table after the inner join statement you are joining with. Please see Rahul's comment

Table 2 is missing here 

DELETE [target table] 

FROM    [table1]         

 INNER JOIN [table2]  

ON [table1.[joining column] = [table2].[joining column]  

WHERE   [condition] 

as per the screen shot it should be {ASHVoteMultipleChoice}

2020-06-17 07-09-57
Ja

pranav pandey wrote:

Hi Ja,

your statement is wrong . Please declare the table after the inner join statement you are joining with. Please see Rahul's comment

Table 2 is missing here 

DELETE [target table] 

FROM    [table1]         

 INNER JOIN [table2]  

ON [table1.[joining column] = [table2].[joining column]  

WHERE   [condition] 

as per the screen shot it should be {ASHVoteMultipleChoice}

Hi Pranav,

Thanks for pointing that i amend my SQL syntax but same error.





2026-02-26 06-29-24
Rahul
 
MVP

Ja wrote:

pranav pandey wrote:

Hi Ja,

your statement is wrong . Please declare the table after the inner join statement you are joining with. Please see Rahul's comment

Table 2 is missing here 

DELETE [target table] 

FROM    [table1]         

 INNER JOIN [table2]  

ON [table1.[joining column] = [table2].[joining column]  

WHERE   [condition] 

as per the screen shot it should be {ASHVoteMultipleChoice}

Hi Pranav,

Thanks for pointing that i amend my SQL syntax but same error.






Hi Ja,

As i am seeing you "inner join" is not in blue color when you write sql.

i think problem is that.can you check inner join is working in your sql

USe below method once.

SyntaxEditor Code Snippet

DELETE {QuestionOptions}

FROM    {QuestionOptions},{Questions}

WHERE  {QuestionOptions}.[QuestionID] =  {Questions}.[Id]

 and {QuestionOptions}.[QuestionID]=1


Regards

Rahul Sahu

2026-02-26 06-29-24
Rahul
 
MVP

Hi Ja,

Look below query in OS


Hope this wil help you.


Regards

Rahul  Sahu

2020-06-17 07-09-57
Ja
Solution

Hi,

Thanks for your input, however i ended up using this suggested syntax

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.