473,405 Members | 2,338 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,405 software developers and data experts.

select inside update?

Hi,
I'm trying to UPDATE a field according to a criteria I SELECT from
another table. I thought I could do that in one statement - but it
gives me an error. I'm doing it from Java. What am I doing wrong?

The update statement:
UPDATE Accounts SET StatusID = (SELECT AcctStatusID FROM AcctStatus
WHERE AcctStatusName = 'Suspended') WHERE AcctID = 192

It produces:
[Microsoft][ODBC Microsoft Access Driver] Operation must use an
updateable query.

Obviously, when I do just
SELECT AcctStatusID FROM AcctStatus WHERE AcctStatusName = 'Suspended'

it gives me the right ID. And if I do

UPDATE Accounts SET StatusID = 4 WHERE AcctID = 192

it also works fine. But not as one statement.

Jan 27 '07 #1
2 10556
UPDATE Accounts, AcctStatus SET StatusID = [AcctStatusID]
WHERE AcctID=192 AND AcctStatusName='Suspended';

Cheers,
Jason Lepack

On Jan 27, 2:05 pm, "Paul" <paul_l...@hotmail.comwrote:
Hi,
I'm trying to UPDATE a field according to a criteria I SELECT from
another table. I thought I could do that in one statement - but it
gives me an error. I'm doing it from Java. What am I doing wrong?

The update statement:
UPDATE Accounts SET StatusID = (SELECT AcctStatusID FROM AcctStatus
WHERE AcctStatusName = 'Suspended') WHERE AcctID = 192

It produces:
[Microsoft][ODBC Microsoft Access Driver] Operation must use an
updateable query.

Obviously, when I do just
SELECT AcctStatusID FROM AcctStatus WHERE AcctStatusName = 'Suspended'

it gives me the right ID. And if I do

UPDATE Accounts SET StatusID = 4 WHERE AcctID = 192

it also works fine. But not as one statement.
Jan 27 '07 #2
Thanks a lot Jason, works perfectly. I didn't know you could include
tables you weren't actually updating in an UPDATE statement.
Paul

On Jan 27, 3:48 pm, "Jason Lepack" <jlep...@gmail.comwrote:
UPDATE Accounts, AcctStatus SET StatusID = [AcctStatusID]
WHERE AcctID=192 AND AcctStatusName='Suspended';

Cheers,
Jason Lepack

On Jan 27, 2:05 pm, "Paul" <paul_l...@hotmail.comwrote:
Hi,
I'm trying to UPDATE a field according to a criteria I SELECT from
another table. I thought I could do that in one statement - but it
gives me an error. I'm doing it from Java. What am I doing wrong?
The update statement:
UPDATE Accounts SET StatusID = (SELECT AcctStatusID FROM AcctStatus
WHERE AcctStatusName = 'Suspended') WHERE AcctID = 192
It produces:
[Microsoft][ODBC Microsoft Access Driver] Operation must use an
updateable query.
Obviously, when I do just
SELECT AcctStatusID FROM AcctStatus WHERE AcctStatusName = 'Suspended'
it gives me the right ID. And if I do
UPDATE Accounts SET StatusID = 4 WHERE AcctID = 192
it also works fine. But not as one statement.
Jan 27 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Marco | last post by:
Hi there ive trying to make a game based on php and currently ive some problems with this part of the script, i've tryed to fix it alone with out success... This is the script <?php...
5
by: jayson_13 | last post by:
Hi, I need to implement a counter and i face problem of locking so hope that u guys can help me. I try to do test like this : 1st connection SELECT * FROM nextkey WHERE tblname = 'PLCN'...
6
by: GSteven | last post by:
(as formerly posted to microsoft.public.access.forms with no result) I've created a continuous form which is based on a straightforward table (ex - customers - 100 records). On the form there is...
2
by: Arjen | last post by:
Hello, I have 2 resource files. The resource files have both inside the name field values. I want to select from the first resource file the records where the name field haves a value between 1...
0
by: simon | last post by:
I have dataRepeater with normal select box: <itemTemplate> <select id='<%# getID()%> '> <option value=0>0</option> (note:'this options are added on client side') <option value=1>1</option>...
19
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
5
by: cdtsly | last post by:
Hi i have a table with all value at 4 i select all lines in a fetch i update one with a value of 7 i update all the row in the fetch with a value 5 the result is that all my row are at 5 and...
6
by: fniles | last post by:
I am using VB.NET 2005 and Access database. My program uses a timer that kicks in every 1 min to read from a database and copy the dataset table to a datatable. This database is in a class called...
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...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.