因此,我为同事编写了以下查询(见下文):
SELECT
t.tender_id as "Tender ID",
t.check_number as "Check Number",
t.check_type_id as "Check Type",
t.server_id as "Server ID",
t.cashier_id as "Cashier ID",
t.terminal_id as "Terminal ID",
t.tendered_date_time as "Tendered Date and Time",
t.tender_amount as "Tender Amount",
t.change_amount as "Change Amount",
g.account_name as "Account Name",
g.account_number as "Account Number"
FROM CheckTender AS t
INNER JOIN AcountActivity AS g
ON t.check_number = g.check_number
WHERE t.tender_id NOT in (5,14,4,9,15,16);
一个支票号码可以有多个tender_ID。因此,例如,您可以为支票编号 20001 设置三行,它们都具有不同的招标 ID。
最初,他只想要删除了tender_id 的任何条目5,14,4,9,15,16
。但是后来我们发现我们需要修改 where 条件。
它需要更新,以便如果支票号码的投标 ID 为5,14,4,9,15,16
,则删除该支票号码的所有实例。我知道这很可能是一个子查询,但我整个早上都在努力解决它,却无法弄清楚。:(