sql - ADODataSet 从连接表中删除

标签 sql delphi delphi-2009 ado tadodataset

我有一个 Delphi 应用程序,在其中显示已通过查询玩过的游戏列表,如下所示:

select  g.*, gt.id, gt.descr 
from GAMES g 
inner join game_types gt on gt.id = g.game_type
order by game_date DESC

当我单击 DBNavigator 中的删除按钮时,game_types 表中的联接记录也会被删除。这是一个问题,因为许多其他游戏可能属于同一类型。

我需要做什么才能只删除游戏而不删除游戏类型?

最佳答案

您需要使用Unique Table动态属性

ADOQuery1.Properties['Unique Table'].Value := 'GAMES';

来自MSDN ADO Documentation

If the Unique Table dynamic property is set, and the Recordset is the result of executing a JOIN operation on multiple tables, then the Delete method will only delete rows from the table named in the Unique Table property.

关于sql - ADODataSet 从连接表中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7981718/

相关文章:

java - 正则表达式替换 <

delphi - VirtualStringTree - 多行节点和垂直居中文本

delphi - PNGImage "Access violation"程序结束时出现错误

delphi - IdTCPServer 如何使用 OnExecute 发送和接收来自特定客户端的应答

delphi - 如何减少 Delphi 中的 PageControl 闪烁?

html - Delphi 的最佳轻量级 HTML 解析器

mysql - 为什么 MySQL AI id 会这样?

sql - 使用 PL/pgSQL 数组时出现查询错误

java - ORA-00917 : missing comma - Insert query failed

delphi - 如何将 ItemIndex 添加到 TRibbonComboBox?