如何删除彼此相关的两个表中的数据? [英] how can i delete data form two table which is related with each other?

查看:210
本文介绍了如何删除彼此相关的两个表中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友
我想从两个表中删除数据,并且两个表r相互重新实现,这意味着一个已提交.
我可以在表中使用联接吗?
我有一个解决方案,该解决方案是两次删除命令,首先删除子级,然后删除父级.
我可以通过其他任何方式从两个表中删除数据,例如join ??
请指导我的朋友

hello friend
i want delete data from two table and both tables r realted with each other means one filed is comman.
can i use join in the tables??
i have one solution that is deleted command two times first deleted child and then parent.
any other way by which i can delete data form both table like join??
plz guide me friends

推荐答案

可以设置级联删除,以便在尝试删除父记录时删除所有相关的子记录.看看这里的例子.

在SQL Server 7中执行级联删除 [ ^ ]

另外,如果要手动删除记录,则应确保使用c#代码或sql在单个事务中删除它们.
You can have cascaded delete set up, so that when you try to delete the parent record all the related child records are deleted. Take a look at the detialed example here.

Performing a Cascade Delete in SQL Server 7[^]

Alternatively, if you are manually deleting records then you should make sure you are deleting them in a single transaction, either in c# code or in sql.


开始

这篇关于如何删除彼此相关的两个表中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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