473,387 Members | 1,535 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,387 software developers and data experts.

Does Subquery nested in Update query work?

Expand|Select|Wrap|Line Numbers
  1. Update contacts set Commonsid = 
  2. (select Commonsid from contacts1 where contactid = contacts.contactid and Commonsid is not null)
  3. where Commonsid is null
This query gives 'Operation must use an updatable query' error. I copied this query to SQLServer 2005, it works fine.

The table 'Contacts1' is copied table of 'Contacts', except that Contacts1 table has values in CommonsID field, while in 'Contacts', the values are null. Contactid is the key for both tables.

I am the database owner, there's no problem of read/write privileges.

Your inputs are highly appreciated.
Apr 9 '08 #1
4 8400
Stewart Ross
2,545 Expert Mod 2GB
Hi. Access is fairly restrictive about what constitutes an updatable query, and what may work in SQL Server may not in Access. There is an MS Knowledge Base article at http://support.microsoft.com/kb/328828/en-us which provides further detail.

You will need to recast your update query to do without the subquery, I reckon.

-Stewart
Apr 10 '08 #2
Hi. Access is fairly restrictive about what constitutes an updatable query, and what may work in SQL Server may not in Access. There is an MS Knowledge Base article at http://support.microsoft.com/kb/328828/en-us which provides further detail.

You will need to recast your update query to do without the subquery, I reckon.

-Stewart
Thank you Stewart. The link is quite helpful for going through all the possibilities. But so far, non of them applies to my query.
could you give me a hint of how to translate this update query into a non-subquery query? thanks :-)
Apr 10 '08 #3
OK. I solved the problem. finally gave up subquery, but used the one below. Still don't why the subquery couldn't work.
Expand|Select|Wrap|Line Numbers
  1. UPDATE contacts as c, contacts1 as c1 SET c.eracommonsid = c1.eracommonsid
  2. where c1.contactid = c.contactid
Apr 10 '08 #4
NeoPa
32,556 Expert Mod 16PB
The way you probably should do this in Jet SQL (Access) is :
Expand|Select|Wrap|Line Numbers
  1. UPDATE Contacts as C INNER JOIN Contacts1 as C1
  2.     ON C.Contactid=C1.Contactid
  3. SET C.eracommonsid=C1.eracommonsid
It may not make much performance difference on small datasets but should be more efficient as it uses the INNER JOIN.
Apr 11 '08 #5

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

Similar topics

2
by: lev | last post by:
CREATE TABLE . ( NULL , , (44) ) ID is non-unique. I want to select all IDs where the last entry for that ID is of type 11.
7
by: Kannan | last post by:
Hello, I have a situation which would essentially use a co-related subquery. I am trying to avoid using a co-related subquery due to its slow performanc and use a join statement instead. Here...
2
by: coryjflynn | last post by:
I am try to update the Gender field for all females of a database with about 15,000 records. So how I started was by searching baby girl names on the web and manipulated some of there lists to...
4
by: shumaker | last post by:
I'm wondering how/why this query works. Trying to get my head wrapped around SQL. Basically the Query deletes from the Import table all records that are already in FooStrings so that when I do an...
2
by: smauldin | last post by:
Why does the execution plan have a nested loop join for a simple select with an UDF in the where clause? Here is the query: select * from test_plan where vCol = my_udf('test') Here is the...
1
by: sivaram | last post by:
Hi all, I have the following query in Visual Foxpro that is throwing error. UPDATE T1 set T1.C2 = (select T2.C2 from T2 where T1.c1 = T2.C1)
7
by: K. Crothers | last post by:
I administer a mechanical engineering database. I need to build a query which uses the results from a subquery as its input or criterion. I am attempting to find all of the component parts of...
22
by: Kevin Murphy | last post by:
I'm using PG 7.4.3 on Mac OS X. I am disappointed with the performance of queries like 'select foo from bar where baz in (subquery)', or updates like 'update bar set foo = 2 where baz in...
5
by: steven.fafel | last post by:
I am running 2 versions of a correlated subquery. The two version differ slightly in design but differ tremendously in performance....if anyone can answer this, you would be awesome. The "bad"...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.