473,608 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UPDATE SET xxx=SELECT Help

Hello everyone,

I'm quite new to ACCESS and I have a fairly good knowledge of SQL under
Oracle. I'm trying to run the following query without any luck:

UPDATE M1L
SET M1L.Code_err = (SELECT M1.Code_err
FROM table_temp M1
WHERE M1L.Forme=M1.Fo rme
AND M1L.PdeD=M1.Pde D
AND M1.Code_Err is not null);
Access gives me a strange error message about not being to update something
with something (I run a French Office) and it's too late for a good
translation. I'm puzzled. Does Access support that kind of query? If not, is
there a work around?

Thanks,
Patrick


Nov 12 '05 #1
2 23450
The closest thing I could come up with that appears to be what you have is

UPDATE M1L INNER JOIN M1 ON (M1L.PdeD = M1.PdeD) AND (M1L.Forme = M1.Forme)
SET M1L.Code_err = [M1].[Code_err]
WHERE ((Not (M1.Code_err) Is Null));

The only problem I see with this is that if M1 has more than one value that meets all 3
criteria, the last one that the query comes to will be the one finally stored in M1L.

Example:
M1.PdeD = A, M1.Forme = B, M1.Code_err = 1
M1.PdeD = A, M1.Forme = B, M1.Code_err = 2

M1L.PdeD = A, M1L.Forme = B, M1L.Code_err = 3

When done, do you want 3 to become 1 or 2? It will depend on the sort order in the query,
the one it comes to last will be the new value in place of 3. The data in your table may
be such that this isn't a problem.

--
Wayne Morgan
"Patrick Drouin" <pa************ @uREMOVE-THISmontreal.ca > wrote in message
news:fB******** *************@c harlie.risq.qc. ca...
Hello everyone,

I'm quite new to ACCESS and I have a fairly good knowledge of SQL under
Oracle. I'm trying to run the following query without any luck:

UPDATE M1L
SET M1L.Code_err = (SELECT M1.Code_err
FROM table_temp M1
WHERE M1L.Forme=M1.Fo rme
AND M1L.PdeD=M1.Pde D
AND M1.Code_Err is not null);
Access gives me a strange error message about not being to update something
with something (I run a French Office) and it's too late for a good
translation. I'm puzzled. Does Access support that kind of query? If not, is
there a work around?

Thanks,
Patrick

Nov 12 '05 #2
Hello Wayne,

"Wayne Morgan" <co************ *************** @hotmail.com> a écrit dans le
message de news:iU******** *********@newss vr16.news.prodi gy.com...
The closest thing I could come up with that appears to be what you have is

UPDATE M1L INNER JOIN M1 ON (M1L.PdeD = M1.PdeD) AND (M1L.Forme = M1.Forme) SET M1L.Code_err = [M1].[Code_err]
WHERE ((Not (M1.Code_err) Is Null));

The only problem I see with this is that if M1 has more than one value that meets all 3 criteria, the last one that the query comes to will be the one finally

stored in M1L.

Thanks, I'll give that a try and see if it works. I don't really mind if
more than one value matches since if I get a value the record will be
scraped regardless of the content. I didn't think of using INNER JOIN to do
that, not a bad idea at all. I like subqueries a lot better though. ;o)

Ciao and thanks again!
P
Nov 12 '05 #3

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

Similar topics

6
3366
by: Paul Eden | last post by:
Hello all. I'm totally stumped. Please de-stump me! I've read my data in from the database, changed it according to what i want to do and now I want to write it back. But it seems I can only use the update statement will only accept explicit fieldnames and value. The fieldnames I can live with, I only have 5 columns in the database, but why can't I pass a $variable to this statement?
1
1798
by: MattMika | last post by:
I am trying to integrate a Credit Card # deletion option into Batch_print_center and need some help. Batch_print_center has a form where you specify orders you want to print or proccess by either entering in a range(ie, 3-9), a comma separated list(ie, 3,4,5,6) or a range by start and end date(ie, yyyy-MM-dd - yyyy-MM-dd)which is a javascript calendar widget. Date_purchased is stored in the DB as 2005-04-12 13:19:13. This first...
7
2573
by: Steve B. | last post by:
Does anyone know why the DA Update() would throw an exception? I moved the database but I updated the Conn and the DA, currently (trying)removing/replacing DS. Is there a another direction I should be looking in? Does it matter if I move columns in the grid (everything is a string anyways)? Does the DS need to be udated from the DT? *************** int rowNo = dg.CurrentRowIndex; dt = dt .Rows.BeginEdit();
0
1187
by: Ash | last post by:
Hi, I'm using Vb.NET webform, connecting to sql server database on the local machine. I used datagrid propery builder to add the edit, update and cancel colum. On the code, i have: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SqlDataAdapter1.Fill(DataSet11) DataGrid1.DataBind()
4
1097
by: Mike | last post by:
I have an update page and on the page there are sometimes names with 's (car's) in it When I try to update it i get a syntax error. How can i update the record with a 's (car's) in the name? thx
5
8321
by: parwal.sandeep | last post by:
Hello grp! i'm using INNODB tables which are using frequently . if i fire a SELECT query which fetch major part of table it usually take 10-20 seconds to complete. in mean time if any UPDATE qry comes for a perticular row which is part of SELECT qry i want to know that whether UPDATE will wait for completing SELECT qry or not, or it simply executing without bothering SELECT qry .
2
1498
by: billr | last post by:
SQL newby in deep water thats way over my head. Any help appreciated. I am trying to retrieve data from field in one table and append it to on field in a second table. Each the fields had a Field ID that is different for each. The rows also have no way to relate to each other without linking through a third table. And just for fun I need to restrict the update to only a subset of the rows in TableB So it looks like this: TableA ...
0
1375
by: Mangler | last post by:
I have a form that does multiple updates on the page. For some reason that I cant figure out it is redirecting before the update is done. It doesnt do this on another page that I have. <% If Request("Submit") <"" Then intRecIDs = Replace(Request("hidRecIDs"), "*", "") ' remove all the asterisks, to create a list like this: 2, 5, 8, 9 etc. arrRecIDs = Split(intRecIDs, ", ") ' Create an array, wich will contain just the IDs of the...
11
3136
by: cooperkuo | last post by:
Dear all, I have a question about ADO in the subform. I know how to use ADO to insert/update/select data into the sigin form, but wehn I try to do it in the form with subform((Datasheet). I don't have any idea how to insert/update/select the recordset data into the subform(Datasheet), especially insert/update. Would someone can give me a idea or sample code to me? Appreciate your help. OS: windows XP +SP2+ Access 2003+SP2 Database: MS...
0
8067
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8010
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8501
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8483
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8157
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5479
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3967
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4030
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1336
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.