Delete query with IN clause

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sophannaly
    New Member
    • Mar 2014
    • 67

    Delete query with IN clause

    Hi,

    I have a problem on deleting data from table with query which where clause use NOT IN. my query is:
    Code:
    DELETE * FROM role WHERE role_name not in ('MOC_PP',' MOC_SR',' MOC_BB')
    but the result just leave only one data row with role_name = 'MOC_PP'.

    Could anybody tell me what is the problem with my query?

    Sophanna
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Hi

    Just guessing, but I suspect you have an extra space in two of the IN list, ie I think it pehaps should be like this
    Code:
    DELETE * FROM role WHERE role_name not in ('MOC_PP','MOC_SR','MOC_BB')
    In your query it would delete all record with with a role_name of MOC_SR and MOC_BB


    MTB

    Comment

    • sophannaly
      New Member
      • Mar 2014
      • 67

      #3
      Hi MTB,

      Thanks you so much, now I could figure out where the problem is.

      Best regards,
      Sophanna

      Comment

      Working...