使用带有WHERE条件的单个查询(SQL Express 2005)从多个表中删除行 [英] Delete rows from multiple tables using a single query (SQL Express 2005) with a WHERE condition
本文介绍了使用带有WHERE条件的单个查询(SQL Express 2005)从多个表中删除行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我正在使用的查询:
This is the query I'm using:
DELETE TB1.*, TB2.*
FROM TB1
INNER JOIN TB2 ON TB1.PersonID = TB2.PersonID
WHERE (TB1.PersonID)='2'
它在MS Access中工作正常,但是在SQL Server Express 2005中出现错误(,"附近的语法不正确).
It's working fine in MS Access but getting error (Incorrect syntax near ','.) in SQL Server Express 2005.
如何解决?请帮忙.
推荐答案
您不能在SQL 2005
中使用单个表达式的多个表中的DELETE
-或任何其他标准SQL. Access
是这里的例外.
You cannot DELETE
from multiple tables with a single expression in SQL 2005
- or any other standard SQL for that matter. Access
is the exception here.
获得此效果的最佳方法是在表之间用ON
DELETE
trigger
指定FOREIGN KEYS
.
The best method to get this effect is to specify FOREIGN KEYS
between the table with an ON
DELETE
trigger
.
这篇关于使用带有WHERE条件的单个查询(SQL Express 2005)从多个表中删除行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文