how does update work with 'not in'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Johnny JL
    New Member
    • Aug 2013
    • 1

    how does update work with 'not in'

    sample:
    Code:
    update tableA 
       set flag = 'N' 
    where id not in 
       (select id 
        from tableA 
        where flag = 'Y')
    Q: how does this query work?
    is system firstly get the list which falg is 'Y', then pick up each id and check if it's in the list, then update accordingly?

    Or

    is system pick up one id and get the list which flag is 'Y' everytime, then update accordingly?
    Last edited by zmbd; Aug 12 '13, 03:10 PM. Reason: [z{placed code tags, stepped SQL}{Is this a Homework Question?}]
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    It sounds like it is...


    ~~ CK

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      I don't understand either one of your descriptions. What it's doing is if an id has a record in the table where the flag is set to Y, don't update that row. Update everything else to N.

      Comment

      • chetan9529
        New Member
        • Aug 2013
        • 4

        #4
        First statement is correct. firstly get the list which falg is 'Y'. then will check with all id's..

        Comment

        Working...