473,378 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to update a field with multiple values with one SQL statement?

I am using Access 2007 on an XP machine. Is it possible to update one field with multiple values using a single SQL statement? I have tired to do this with the query builder, but keep getting a "duplicate output destination" error (I think it is error #3063). This is the code that Access "builds" for me, but does not run:

UPDATE Sept_8_2008_GRE SET Sept_8_2008_GRE.[Chem Interest Area 1] = "b", Sept_8_2008_GRE.[Chem Interest Area 1] = "b ,p", Sept_8_2008_GRE.[Chem Interest Area 1] = " "
WHERE ( (((Sept_8_2008_GRE.[Chem Interest Area 1])="202" Or (Sept_8_2008_GRE.[Chem Interest Area 1])="206") And (Sept_8_2008_GRE.[Chem Interest Area 1])="222" And ((Sept_8_2008_GRE.[Chem Interest Area 1])="301" Or (Sept_8_2008_GRE.[Chem Interest Area 1])="399") ));

I have also tired this, but now I get a syntax error:
UPDATE Sept_8_2008_GRE SET Sept_8_2008_GRE.[Chem Interest Area 1] = CASE WHEN [Chem Interest Area 1] IN ("202" OR "206") THEN [Chem Interest Area 1]=("b")
WHEN [Chem Interest Area 1] IN ("222") THEN [Chem Interest Area 1]=("b, p") WHEN [Chem Interest Area 1] IN ("301" OR "399") THEN [Chem Interest Area 1]=(" ") END;

Can anyone help? I need to be able to do this update in one step!

Thanks,
Sara
Oct 27 '08 #1
1 4147
I am using Access 2007 on an XP machine. Is it possible to update one field with multiple values using a single SQL statement? I have tired to do this with the query builder, but keep getting a "duplicate output destination" error (I think it is error #3063). This is the code that Access "builds" for me, but does not run:

UPDATE Sept_8_2008_GRE SET Sept_8_2008_GRE.[Chem Interest Area 1] = "b", Sept_8_2008_GRE.[Chem Interest Area 1] = "b ,p", Sept_8_2008_GRE.[Chem Interest Area 1] = " "
WHERE ( (((Sept_8_2008_GRE.[Chem Interest Area 1])="202" Or (Sept_8_2008_GRE.[Chem Interest Area 1])="206") And (Sept_8_2008_GRE.[Chem Interest Area 1])="222" And ((Sept_8_2008_GRE.[Chem Interest Area 1])="301" Or (Sept_8_2008_GRE.[Chem Interest Area 1])="399") ));

I have also tired this, but now I get a syntax error:
UPDATE Sept_8_2008_GRE SET Sept_8_2008_GRE.[Chem Interest Area 1] = CASE WHEN [Chem Interest Area 1] IN ("202" OR "206") THEN [Chem Interest Area 1]=("b")
WHEN [Chem Interest Area 1] IN ("222") THEN [Chem Interest Area 1]=("b, p") WHEN [Chem Interest Area 1] IN ("301" OR "399") THEN [Chem Interest Area 1]=(" ") END;

Can anyone help? I need to be able to do this update in one step!

Thanks,
Sara

It looks like MS Access can't use CASE ... but has a function called SWITCH. This will run, but the result is a blank field. Not sure what I am doing wrong.
UPDATE Sept_8_2008_GRE SET
ChemInterestArea1 = SWITCH(ChemInterestArea1 IN ("202", "206"), "b",
ChemInterestArea1="222", "b, p" ;
Oct 28 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Roy Adams | last post by:
Hello people I've recently been woring with multiple insert from text fields and got that woking fine thanks to the help from people from this forum now i'm trying to deal with multiple update,...
7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
2
by: KathyB | last post by:
Hi, figured out where I was going wrong in my post just prior, but is there ANY way I can assign several variables to then use them in an Update statement, for example (this does not work): ...
8
by: Lauren Quantrell | last post by:
In VBA, I constructed the following to update all records in tblmyTable with each records in tblmyTableTEMP having the same UniqueID: UPDATE tblMyTable RIGHT JOIN tblMyTableTEMP ON...
1
by: mirth | last post by:
I would like to update a decimal column in a temporary table based on a set of Glcodes from another table. I search for a set of codes and then want to sum the value for each row matching the...
3
by: Epetruk | last post by:
Hi, I have a mySql question here on updates to multiple tables. Here's a simple schema to clarify things: Structure Table A
2
by: Mike Leahy | last post by:
Hello all, This question is related to updating tables - is there any way to calculate or update the values in a column in a table to the values in a field produced by a query result? An...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
4
by: hapnendad | last post by:
In the question statement below Field names are in and variables are in (). All fields referenced are in what I have named the ‘PAR’ Table. Using MS Access 2003, I am working on a project...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.