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.




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

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

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




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}

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,

Look below query in OS


Hope this wil help you.


Regards

Rahul  Sahu

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

Solution

Hi,

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

Solution