这个查询可能非常荒谬,或者我只是有一点小错误。我不太确定。但基本上我正在尝试使用 Access 中另一个表中的数据更新一个表。给我问题的列是那些设置为“是/否”类型的列,而我试图更新它的数据设置为“文本”类型,其值为字符串“是”或“否”。
因此,如果可能的话,我对这个查询的想法是将“文本”字段大致转换为 1 或 0,具体取决于它们的 Yes 或 No 值。无论如何,足够的背景,这里是查询:
UPDATE Group_Pricing SET
Contract_Type = (SELECT Contract_Type FROM ContractTypesFinal WHERE ContractTypesFinal.FirstGroup = Group_Pricing.GroupID),
Hybrid_Retail =
(SELECT CASE (SELECT RetailSpread FROM ContractTypesFinal WHERE ContractTypesFinal.FirstGroup = Group_Pricing.GroupID)
CASE "Yes"
RetailSpread = 1
CASE "No"
RetailSpread = 0),
Hybrid_Mail =
(SELECT CASE (SELECT MailSpread FROM ContractTypesFinal WHERE ContractTypesFinal.FirstGroup = Group_Pricing.GroupID)
CASE "Yes"
MailSpread = 1
CASE "No"
MailSpread = 0),
Hybrid_Specialty =
(SELECT CASE (SELECT SpecialtySpread FROM ContractTypesFinal WHERE ContractTypesFinal.FirstGroup = Group_Pricing.GroupID)
CASE "Yes"
SpecialtySpread = 1
CASE "No"
SpecialtySpread = 0),
Hybrid_Rebates =
(SELECT CASE (SELECT Rebates FROM ContractTypesFinal WHERE ContractTypesFinal.FirstGroup = Group_Pricing.GroupID)
CASE "Yes"
Rebates = 1
CASE "No"
Rebates = 0)
WHERE EXISTS (SELECT 1 FROM ContractTypesFinal WHERE ContractTypesFinal.FirstGroup = Group_Pricing.GroupID);
任何帮助深表感谢。如果这不可能,就告诉我我是个白痴。谢谢!