我有以下表格:
Country: Country_ID, CountryName
Regions: Region_ID, RegionName, Country_ID
Areas: Area_ID, AreaName, RegionID
Run Code Online (Sandbox Code Playgroud)
我没有使用外键而且没有计划这样做,我现在要做的就是能够在tableAdapter of country table中的一个查询中删除国家和所有相关区域,区域......
怎么样?
Jon*_*jap 11
在一个查询?我怀疑你能.
但是你可以用三个来做:
delete from Areas where RegionID in (select Region_ID from Regions where Country_ID in (select Country_ID where CountryName='Somelandia'))
delete from Regions where Country_ID in (select Country_ID where CountryName='Somelandia')
delete from Country where CountryName = 'Somelandia'
Run Code Online (Sandbox Code Playgroud)
话虽如此,我强烈建议您重新考虑使用外键关系和级联删除为此目的.
| 归档时间: |
|
| 查看次数: |
2391 次 |
| 最近记录: |