Solved

Update Query

Posted on 2013-01-20
9
254 Views
Last Modified: 2013-01-21
Experts,

I need to confirm what this update query says.
The where condition is saying: dont update if ([import-CSM2].LCID) IS NOT IN [tblLetterOfCredit].[LetterOfCreditID]  but it will update if ([import-CSM2].LCID) IS IN [tblLetterOfCredit].[LetterOfCreditID]

I hope that makes sense.  


UPDATE [import-CSM2] INNER JOIN tblLetterOfCredit ON [import-CSM2].[Reference Number] = tblLetterOfCredit.LCNo SET [import-CSM2].LCID = [tblLetterOfCredit].[LetterOfCreditID]
WHERE ((([import-CSM2].LCID) Not In (SELECT [tblLetterOfCredit].[LetterOfCreditID] From [tblLetterOfCredit])) AND (([import-CSM2].[Actual Status])<>"GEC"));
0
Comment
Question by:pdvsa
  • 6
  • 2
9 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 38799643
I believe you've got things backwards.

Your query as is WILL update if

[import-CSM2].LCID Is Not found In [tblLetterOfCredit].[LetterOfCreditID]
0
 
LVL 29

Expert Comment

by:becraig
ID: 38799644
It is saying update ONLY if the following two conditions are met:
1. import-CSM2].[Actual Status])<>"GEC"
2. import-CSM2].LCID is not present in SELECT [tblLetterOfCredit].[LetterOfCreditID] From [tblLetterOfCredit]
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38799648
Try this instead:

UPDATE [import-CSM2] INNER JOIN tblLetterOfCredit ON [import-CSM2].[Reference Number] = tblLetterOfCredit.LCNo
AND [import-CSM2].LCID  = SELECT [tblLetterOfCredit].[LetterOfCreditID]
 SET [import-CSM2].LCID = [tblLetterOfCredit].[LetterOfCreditID]

Open in new window

0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 61

Expert Comment

by:mbizup
ID: 38799652
Correction to include the <> GEC:

UPDATE [import-CSM2] INNER JOIN tblLetterOfCredit ON [import-CSM2].[Reference Number] = tblLetterOfCredit.LCNo
AND [import-CSM2].LCID  = SELECT [tblLetterOfCredit].[LetterOfCreditID]
SET [import-CSM2].LCID = [tblLetterOfCredit].[LetterOfCreditID]
WHERE [import-CSM2].[Actual Status] <>"GEC"

Open in new window

0
 

Author Comment

by:pdvsa
ID: 38799660
mbizup:  

Do you see a syntax in the response right above?  It says there is one.  It highlights [import-CSM2].[Reference Number]  on the first line.  

thanks...
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 38799693
Yup -- copy/paste issues.  I got the SELECT in there by mistake.

Try this:

UPDATE [import-CSM2] INNER JOIN tblLetterOfCredit 
ON [import-CSM2].[Reference Number] = tblLetterOfCredit.LCNo
AND [import-CSM2].LCID  = [tblLetterOfCredit].[LetterOfCreditID]
 SET [import-CSM2].LCID = [tblLetterOfCredit].[LetterOfCreditID]
WHERE [import-CSM2].[Actual Status] <>"GEC"

Open in new window

0
 
LVL 61

Expert Comment

by:mbizup
ID: 38799703
Or try this:

UPDATE [import-CSM2] INNER JOIN tblLetterOfCredit ON [import-CSM2].[Reference Number] = tblLetterOfCredit.LCNo SET [import-CSM2].LCID = [tblLetterOfCredit].[LetterOfCreditID]
WHERE [import-CSM2].LCID IN (SELECT [tblLetterOfCredit].[LetterOfCreditID] From [tblLetterOfCredit]) AND [import-CSM2].[Actual Status] <>"GEC";

Open in new window

0
 

Author Comment

by:pdvsa
ID: 38799727
perfect.   These queries are difficult.  Both SQL's returned same number of records.

thank you!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38799759
If they both worked okay, I would opt for the first... I believe it would be better performance-wise.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now