我们如何用一个查询语句删除多个表数据 [英] how can we delete multiple table data with a single query statement

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

问题描述

大家好,
我必须在带有where条件的sqlcommandquery中使用一条查询语句删除多个(两个或三个)表数据行.可能吗?如果可能的话,我们该怎么办?

在此先感谢

hi all,
i have to delete multiple(two or three) table data rows with one query statement in sqlcommandquery with where condition. is it possible? if possible then how can we do it?

thanks in advance

推荐答案

最好写一个存储过程,它接受您的所有条件
并逐个或使用事务方式执行删除语句.
Better to write a Stored Procedure, that accepts your all conditions
and execute your delete statements one by one or using transaction way.


您必须为每个表编写一条删除语句.我相信不可能仅使用一个Where语句从三个表中删除,除非这些表之间存在允许级联删除的关系.
You have to write a delete statement for each Table. I believe it''s not possible to delete from three tables using only one Where statement, unless there is a relationship between these tables allowing a Cascade Delete.


亲爱的朋友,

使用StoredProcedure并实现所有方法如果要删除表中的总数据,请使用Truncate.


问候,

Anilkumar.D
Dear Friend,

Use StoredProcedure and Implement all methods What ever you Required if yo want to Delete total Data in Table use Truncate.


Regards,

Anilkumar.D


这篇关于我们如何用一个查询语句删除多个表数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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