我正在尝试对数据库运行多次删除,但是当它运行时,它没有错误但没有删除任何内容吗?如果即使其中一个表都没有任何内容可以链接到另一个表,内部联接是否会失败?
在Express.js api中使用查询,我正在努力完成我们的工作。
我通常先在DBMS中测试像这样的大查询,然后再将它们放入我的api中。
以下是查询:
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;
我的逻辑有错误吗?如果是的话,那是什么?还是在我不知道的情况下删除?
您可能会问的问题:
我是否尝试搜索堆栈溢出? ANS:是的,我确实做到了,但似乎找不到适合这种奇怪情况的答案
所以没有错误? ANS:运行查询时没有错误
答案 0 :(得分:0)
尝试查看该主题: How to Delete using INNER JOIN with SQL Server?
据我所见,您需要为每个表指定别名。 所以任务,问题...是别名,但是在内部联接表名之后看不到任何别名 (是的,名称与表相同,但可能需要别名) 例如:INNER JOIN任务任务已开启... (现在,任务是别名,因此您可以从表任务中删除) 没有检查它,但是如果要工作,那就应该解决。