繁体   English   中英

如何解决此错误“ MySQL错误:1109(MULTI DELETE中的未知表'table_name')”?

[英]How to resolve this error “MySQL Error: 1109 (Unknown table 'table_name' in MULTI DELETE)”?

我在运行以下查询时将PHP和MySQL(服务器版本:5.5.31-0ubuntu0.12.04.2)用于我的网站,这给了我上面的错误。 我看不到这个错误的任何线索。 谁能帮助我解决此错误并建议对现有查询进行更改(如有)? 供您参考,我在下面编写查询:

DELETE
   ABC.theory_sheet_set,
   ABC.theory_sheet_questions
FROM
   ABC.theory_sheet_set AS theory_sheet_set,
   OCN.theory_sheet_questions AS theory_sheet_questions
WHERE
   theory_sheet_set.theory_sheet_set_id = theory_sheet_questions.theory_sheet_set_id
   AND theory_sheet_set.theory_sheet_id=".$theory_sheet_id

它给出的错误如下:

MySQL Error: 1109 (Unknown table 'theory_sheet_set' in MULTI DELETE)
Session halted.

我的数据库名称是ABC 实际上,所有表名都是有效的,并且此查询中涉及的所有表都存在于数据库中。 您能帮我解决这个问题吗?

如果您在查询的开头(即单词DELETE之后 )使用稍后在查询中使用的别名,则它将正常工作。 唯一的问题是,由于您已经使用别名将这些表引用到数据库中,因此无法从数据库中识别该表。 因此,要消除此错误,您必须在DELETE之后使用在查询中使用的别名。 纠正的查询将如下所示:

DELETE theory_sheet_set, theory_sheet_questions FROM ABC.theory_sheet_set AS theory_sheet_set, ABC.theory_sheet_questions AS theory_sheet_questions  WHERE theory_sheet_set.theory_sheet_set_id=theory_sheet_questions.theory_sheet_set_id AND  theory_sheet_set.theory_sheet_id="$theory_sheet_id

有语法错误,请尝试

DELETE *
FROM
theory_sheet_set theory_sheet_set
INNER JOIN 
theory_sheet_questions theory_sheet_questions ON  
theory_sheet_set.theory_sheet_set_id = theory_sheet_questions.theory_sheet_set_id
WHERE theory_sheet_set.theory_sheet_id=".$theory_sheet_id

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM