I'm trying to run a multi delete on a my database but when it runs it runs with no errors but nothing was deleted? is it a case that an inner join will fail if even one of the table doesn't have anything to link to another and on?
using the query in an Express.js api I'm trying to finish us.
I usual test big queries like this in DBMS before i place them in my api.
below is the query:
DELETE task,issue,milestone,help_source,project_task,project_source,project_milestone,task_created_by,mileStone_created_by,issue_created_by,source_created_by,task_issue,milestone_task,project_creation,project
from project_creation
INNER JOIN project_milestone ON project_milestone.projectId = project_creation.projectId
INNER JOIN project_task ON project_task.projectId = project_creation.projectId
INNER JOIN project_source ON project_source.projectId = project_creation.projectId
INNER JOIN task_created_by ON task_created_by.taskId = project_task.taskId
INNER JOIN mileStone_created_by On mileStone_created_by.mileStoneId = project_milestone.mileStoneId
INNER JOIN source_created_by ON source_created_by.sourceId = project_source.sourceId
INNER JOIN task_issue ON task_issue.taskId = project_task.taskId
INNER JOIN issue_created_by ON issue_created_by.issueId = task_issue.issueId
INNER JOIN milestone_task On milestone_task.taskId = project_task.taskId
INNER JOIN task On task.taskId = project_task.taskId
INNER JOIN issue ON issue.issueId = task_issue.issueId
INNER JOIN milestone ON milestone.mileStoneId = project_milestone.mileStoneId
INNER JOIN help_source On help_source.sourceId = project_source.sourceId
INNER JOIN project ON project.projectId = project_creation.projectId
WHERE project.projectId = 59;
is there some error in my logic? and if yes what is it? or is it deleting without me knowing?
Questions you may ask:
Did i try searching stack overflow? ANS: yes i did but can't seem to find an answer that fits this weird situation
so there is no error? ANS: no there is no errors when i run the query
try to look on that topic : How to Delete using INNER JOIN with SQL Server?
As far as I could see you need to specify aliases for each table. So task, issue... are aliases but cannot see any of then after inner-join table name (true, same names as tables but maybe alias are required) Eg: INNER JOIN task task ON... (now task is an alias, so you delete from table task) Didn't check it, but if is to be work that should be the fix.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.