我们可以使用join一次删除两个表中的一条记录吗 [英] can we delete a record at a time in two tables using join

查看:112
本文介绍了我们可以使用join一次删除两个表中的一条记录吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我们如何使用联接一次删除两个表中的一条记录.

此查询有什么问题
查询:

Hi frnds,

how can we delete a record at a time in two tables using joins.

what''s wrong in this query
Query:

delete from admin from client c INNER JOIN admin a on a.mstr_id=c.mstr_id where c.padm_id=2020


请更正此


Please correct this one

推荐答案

您应该对另一张表具有外键,并将其配置为级联删除.这样,如果没有更多引用,将删除该引用记录.看看更多信息的链接:
http://www.mssqlcity.com/Articles/General/using_constraints.htm [ ^ ]

祝你好运!
You should have a foreign key to the other table and configure it to cascade delete. In this way the referenced record will be deleted if there are no more references to it. Have a look at the link for more info:
http://www.mssqlcity.com/Articles/General/using_constraints.htm[^]

Good luck!


引用此链接:

http://stackoverflow.com/questions/2696565/deleting-records-from-multiple-tables-at-a-time-with-a-single-query-in-sqlserver [
Refer this link:

http://stackoverflow.com/questions/2696565/deleting-records-from-multiple-tables-at-a-time-with-a-single-query-in-sqlserver[^]


这篇关于我们可以使用join一次删除两个表中的一条记录吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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