多表删除 [英] multiple table delete

查看:96
本文介绍了多表删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试执行此sql语法.它从多个表中删除,但我似乎无法正确处理.我检查以确保它符合mysql手册中的内容,但仍然无法正常工作.调试器告诉我某处有不必要的逗号(,).任何帮助.代码中已经设置了"id"字段


I have been trying to execute this sql syntax. its to delete from multiple tables but i cant seem to get it right. i checked to make sure it conforms with the one in the mysql manual but it still wont work. the debugger tells me there is a unnecessary comma(,) somewhere. any help. the ''id'' field is already set in the code


sql = "delete from apps, contacts, firstdeg, hnd, interview, other, secdeg, thirddeg using apps join contacts on apps.FileLoc = contacts.FileLoc join firstdeg on apps.FileLoc = firstdeg.FileLoc join hnd on apps.FileLoc = hnd.FileLoc join interview on apps.FileLoc = interview.FileLoc join other on apps.FileLoc = other.FileLoc join secdeg on apps.FileLoc = secdeg.FileLoc join thirddeg on apps.FileLoc = thirddeg.FileLoc where apps.FileLoc = ''"+id+"''";

推荐答案

您没有从多个表中删除的内容.删除时使用级联.如果存在关联,则来自其他表的其他记录将被自动删除.要知道级联谷歌它.如果没有关系btwn表,则只需编写单独的语句.
You don''t have delete from multiple table. Use cascade while deleting. Another records from other tables will be automatically deleted if there is a relation. To know about cascade google it. If there is no relation btwn tables just make separate statements.


一般语法为:

从表名WHERE条件中删除
The general syntax is:

DELETE FROM tablename WHERE condition


这篇关于多表删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆