我正在尝试删除所有用户,但出现错误:
Msg 547, Level 16, State 0, Line 1
The DELETE statement conflicted with the REFERENCE constraint "FK_M02ArticlePersons_M06Persons". The conflict occurred in database "workdemo.no", table "dbo.M02ArticlePersons", column 'M06PersonId'.
The statement has been terminated.
Run Code Online (Sandbox Code Playgroud)
查询:
DELETE FROM [workdemo.no].[dbo].[M06Persons]
WHERE ID > '13'
GO
Run Code Online (Sandbox Code Playgroud)
似乎我需要使用,on delete cascade;
但我被卡住了。
这个查询给了我多个点击,因为每个assetid
可能包含很多vb.title
. 如何将结果限制为每个仅 1 次命中assetid
?
'select DISTINCT v.id,
v.purchasedate,
v.customerid,
v.assetid,
va.description,
vb.title
from purchases v,
asset va,
assetdescription vb
where customerid = '$kid'
and v.assetid = va.id
and vb.assetid = va.id
order by v.purchasedate'
Run Code Online (Sandbox Code Playgroud)