update version of SQL update question (sorry for confusion)

Posted on 2007-07-30
Last Modified: 2010-03-20
This is an updated version of questions posted by me before
(SQL update/set more than one column 7/30/07 and SQL update logic 7/28/07).
I hope this version is clear.
I have four tables:
Table1, Table2, Table3, and Table4
Table1 and Table2 have common column id. Table2 has columns that can be matched with columns in Table3 and Table4.
I need to join Table1 and Table2 and update column in Table1 depending on different conditions
(1)      when Table2.colA = Table3.ColA and Table2.colB = Table3.ColB Then 1 (set to 1 if a match and dont check anything else)
(2)      when Table2.colA=Table4.ColA and Table2.colB = Table4.ColB  Then 2 (set to 2 if a match and dont check anything else)
else  3

If there is no match for when (1) and when (2) then set the value to 3.
Question by:jgordin
    LVL 14

    Accepted Solution

    For MsAccess Jet:
        (( [Table1] T1
           [Table2] T2
        ON T1.[Key] = T2.[Key]
           [Table3] T3
        ON T2.[ColA] = T3.[ColA]
       AND T2.[ColB] = T3.[ColB]
           [Table4] T4
        ON T2.[ColA] = T4.[ColA]
       AND T2.[ColB] = T4.[ColB]
       SET T1.[MyField] = IIF(ISNULL(T3.[ColA], 2, 1)
         ( ISNULL(T3.[ColA]) <> True  
       AND ISNULL(T3.[ColB]) <> True  
         ) OR
         ( ISNULL(T4.[ColA]) <> True  
       AND ISNULL(T4.[ColB]) <> True  
    LVL 14

    Expert Comment


    Respectfully, why the B grade?..

    What part of your question did I not respond to? and if I did, what additional comment of yours did I miss? Quite frankly, what more could I have done with the information you provided?
    LVL 14

    Expert Comment

    jgordin.. please take a moment and read the grading guidelines:

    What's the right grade to give?

    Although we use an A-C scale here at Experts Exchange, it works differently than, say, school grades. If one or more Experts' proposals are accepted as answers, they should usually be given an A or B grade, since they have taken the time to provide you with a working solution. If a possible solution is incomplete, ask for clarification or details before accepting the answer and grading it. People should not be given lower grades because of incorrect grammar or because you just accepted their answer or comment to close the question. The following is a good guideline to follow when grading:

    A: The Expert(s) either provided you with a thorough answer or they provided you with a link to information that thoroughly answered your question. An "A" can also be given to any answer that you found informative or enlightening beyond the direct question that you asked.

    B: The Expert(s) provided an acceptable solution, or a link to an acceptable solution, that you were able to use, although you may have needed a bit more information to complete the task.

    C: Because Experts' reliability are often judged by their grading records, many Experts would like the opportunity to clarify if you have questions about their solutions. If you have given the Expert(s) ample time to respond to your clarification posts and you have responded to each of their posts providing requested information; or if the answers, after clarification, lack finality or do not completely address the issue presented, then a "C" grade is an option. You also have the option here of just asking Community Support to delete the question.

    Remember, the Expert helping you today is probably going to be helping you next time you post a question. Give them a fair chance to earn an 'Excellent!' grade and they'll provide you with some amazing support. It's also true that a "C" is the lowest grade you can give, and the Experts know that -- so use it judiciously.

    The use of a C in a vindictive manner is likely to be changed by a Moderator. You may not like the answer you get, and in some cases, and you may not like the way it is delivered, but if it is deemed to be accurate, no less than a B is an acceptable grade.


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
    Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    754 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

    19 Experts available now in Live!

    Get 1:1 Help Now