473,473 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Update Query on 2 Tables? Bad Code?

hi everybody-

it seems like my update query should work. the sql view seems logical.
but that might be up to discussion...lol...i'm a newbie!
UPDATE [Case], Issue SET [Case].IssueID = [Issue].[IssueID]
WHERE (([Case].[IssueDesc]=[Issue].[IssueDesc]));
i've got 2 tables, CASE and ISSUE.

.................................................. .............................
CASE

caseid issueid issuedesc
100 0 age
200 0 drugs
300 0 sex
ISSUE
issueid issuedesc
1 age
2 drugs
3 sex
.................................................. .............................

all of the "issueid" fields in CASE are "0."

can i write an update query so that the correct issueid numbers are
associated with the correct issue descriptions in the table, CASE?

so that after the query runs, the CASE table looks like this:

.................................................. .............................
CASE

caseid issueid issuedesc
100 1 age
200 2 drugs
300 3 sex
.................................................. .............................

in design view, i have the CASE and ISSUE tables, and i tried the
query:

UPDATE [Case], Issue SET [Case].IssueID = [Issue].[IssueID]
WHERE (([Case].[IssueDesc]=[Issue].[IssueDesc]));

Field: IssueID
Table: Case
Update To: [Issue].[IssueID]
Criteria: [Case].[IssueDesc]=[Issue].[IssueDesc]

when i clicked "view," it returned one row, caseid, with my 200+
fields i wanted to change from "0" to the correct number. but they all
still had "0."

it seems like it would be an easy enough thing to do, but maybe i've
overlooked something! entirely possible...lol...
RICK COLLARD suggested:

UPDATE Issue RIGHT JOIN Case ON Issue.IssueDesc = Case.IssueDesc SET
Case.IssueID = Issue.IssueID;

THANKS RICK!
i couldn't get it to work though. i'm new with using access and using
aql in access.

thanks everybody,

megan robertson
Nov 12 '05 #1
3 2287
"Megan" <me**************@hotmail.com> wrote in message
news:5c*************************@posting.google.co m...
hi everybody-

it seems like my update query should work. the sql view seems logical.
but that might be up to discussion...lol...i'm a newbie!
UPDATE [Case], Issue SET [Case].IssueID = [Issue].[IssueID]
WHERE (([Case].[IssueDesc]=[Issue].[IssueDesc]));
i've got 2 tables, CASE and ISSUE.

.................................................. ...........................
... CASE

caseid issueid issuedesc
100 0 age
200 0 drugs
300 0 sex
ISSUE
issueid issuedesc
1 age
2 drugs
3 sex
.................................................. ...........................
...


update CASE as c inner join ISSUE as i
on c.issuedesc = i.issuedesc
set c.issueid = i.issueid


Nov 12 '05 #2
"John Winterbottom" <as******@hotmail.com> wrote in message news:<2g************@uni-berlin.de>...
"Megan" <me**************@hotmail.com> wrote in message
news:5c*************************@posting.google.co m...
hi everybody-

it seems like my update query should work. the sql view seems logical.
but that might be up to discussion...lol...i'm a newbie!
UPDATE [Case], Issue SET [Case].IssueID = [Issue].[IssueID]
WHERE (([Case].[IssueDesc]=[Issue].[IssueDesc]));
i've got 2 tables, CASE and ISSUE.

.................................................. ..........................
..
CASE

caseid issueid issuedesc
100 0 age
200 0 drugs
300 0 sex
ISSUE
issueid issuedesc
1 age
2 drugs
3 sex

.................................................. ..........................
..


update CASE as c inner join ISSUE as i
on c.issuedesc = i.issuedesc
set c.issueid = i.issueid

Thanks! But I'm unsure of how to use this. I went into Query Design
View, Added the tables, CASE and ISSUE, then changed to SQL View and
entered your code:

update CASE as c inner join ISSUE as i
on c.issuedesc = i.issuedesc
set c.issueid = i.issueid
After I ran it, I still got all "0's" for my "issueid."

In Design View, your code changed my Table Names from CASE to "c" and
ISSUE to "i."

In the bottom part of the Design View window,
Field: IssueID
Table: c
Update To: i.issueid
Criteria: blank

Am I just dense or something and missed your point?

By the way, I'm searching Access Help to see if there's a way to just
run SQL without going into Query Design View.

Thanks for your help! I'll keep trying!

Megan
Nov 12 '05 #3
"Megan" <me**************@hotmail.com> wrote in message
news:5c**************************@posting.google.c om...

Thanks! But I'm unsure of how to use this. I went into Query Design
View, Added the tables, CASE and ISSUE, then changed to SQL View and
entered your code:
In query design view go straight to sql view and paste the code. But doing
it as above shouldn't affect the result. If it's not working then something
else is going on.

update CASE as c inner join ISSUE as i
on c.issuedesc = i.issuedesc
set c.issueid = i.issueid
After I ran it, I still got all "0's" for my "issueid."

In Design View, your code changed my Table Names from CASE to "c" and
ISSUE to "i."
The tables are aliased - so you don't have to keep typing the table name if
you're writing the sql by hand. Not neccessary though.

In the bottom part of the Design View window,
Field: IssueID
Table: c
Update To: i.issueid
Criteria: blank

try running this code (SQL view)

select * from CASE as c inner join ISSUE as i
on c.issuedesc = i.issuedesc
this will show you which rows will be updated. If it doesn't return any
records means your issuedesc columns do not match up




Nov 12 '05 #4

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

Similar topics

0
by: Jerry Brenner | last post by:
Our users have potentially dirty legacy data that they need to get into our application. We provide a set of staging tables, which map to our source tables, that the users do their ETL into. ...
3
by: Dan Berlin | last post by:
I have two tables: T1 : Key as bigint, Data as char(20) - size: 61M records T2 : Key as bigint, Data as char(20) - size: 5M records T2 is the smaller, with 5 million records. They both have...
4
by: rdraider | last post by:
I am looking for some assistance with an update query that needs to link 3 tables: This query ran and reported over 230,000 records affected but did not change the field I wanted changed, not...
17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
10
by: Hank1234 | last post by:
Can I use one Data Adapter and one Command Builder to update amny tables? Currently in my data adapter I query two tables and fill them into two tables in a data set. When I make a change to a...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
8
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
4
by: dstorms | last post by:
I'm trying to run an update query on multiple tables, and since Access doesn't allow me to update tables from a union query, I'm writing a module as a workaround. So I've set up a temporary recordest...
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,...
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.