Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2007
    Posts
    34

    Unanswered: WHERE clause question

    hi,

    when i use this WHERE clause,

    UPDATE physician

    SET physician_practiceArea_1 = 'heart attack'

    WHERE physician_spec = ('Cardiology' OR 'Invasive Cardiology' or 'Noninvasive and Invasive Cardiology')

    the entire column of physician_spec is updated (not just cardiology), without regard to the where clause. if i break it out and run each separately, it works fine.
    for example,

    .... WHERE physician_spec = cardiology

    is there a way to make modiy that WHERE statement to make it work? Thanks.

    Mike

  2. #2
    Join Date
    Mar 2004
    Posts
    480
    yes change your = to the word IN and then leave your clause as is.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    and change the ORs to commas, i.e.

    WHERE physician_spec IN ('Cardiology' , 'Invasive Cardiology' , 'Noninvasive and Invasive Cardiology')

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    Just to clarify for you where your statement was going wrong:
    WHERE physician_spec = ('Cardiology' OR 'Invasive Cardiology' OR 'Noninvasive and Invasive Cardiology')
    i believe this gets intepreted as WHERE physician_spec = (TRUE).
    What you ought to have had would have been :
    WHERE (physician_spec = 'Cardiology') OR (physician_spec = 'Invasive Cardiology') OR (physician_spec = 'Noninvasive and Invasive Cardiology')

    However, the "IN" answer that has been provided by Rudy is the best...

  5. #5
    Join Date
    Feb 2007
    Posts
    34
    thanks a million. great forum.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •