Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to update one table with data from separate table using conditionals
    text
    copied!<p>This query may be absolutely ridiculous or maybe I just have one little thing wrong. I'm not quite sure. But basically I'm trying to update a table with data from another table in Access. The columns that are giving me issues are those set to "Yes/No" types and the data I'm trying to update it with are set to "Text" types whose values are strings "Yes" or "No."</p> <p>So what I had in mind with this query, if it's even possible, is to roughly convert it the "Text" fields to 1's or 0's depending on their Yes or No values, respectively. Anyway, enough background, here's the query:</p> <pre><code>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); </code></pre> <p>Any help is much appreciated. If this is impossible, just tell me I'm an idiot. Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload