如何实现多表删除?

来源:百度知道 编辑:UC知道 时间:2024/06/15 03:12:12
写的语句是:use ST_DataBase
delete from Course where Course_id IN(Select Course_id From Course_time)
select * from Course
GO
错误是:服务器: 消息 547,级别 16,状态 1,行 2
DELETE 语句与 COLUMN REFERENCE 约束 'FK_Course_time_Course' 冲突。该冲突发生于数据库 'ST_DataBase',表 'Course_time', column 'Course_id'。
语句已终止。

(所影响的行数为 7 行)

你可以这样试试
conn.execute "delete from Shop where Shop_id="& Getshop_id

conn.execute "delete from Product where hop_id="&Getshop_id
如果是数据QLSERVER执行多少句都没问题,把sql语句用分号分开就可以了不需要多多写些conn.execute直接一个而且delete语句不带from也行,conn.execute "delete Shop where Shop_id="& Getshop_id;delete Product where Shop_id="&Getshop_id