Professional Web Applications Themes

switching between IN and NOT IN statements - Microsoft SQL / MS SQL Server

example SELECT field FROM table WHERE field2 IN (SELECT field3 FROM table2..etc i would like to alternate between th "IN" and "NOT IN" statement in the above based on the result of another field in another table can anyone help please regards Carlton...

  1. #1

    Default switching between IN and NOT IN statements

    example

    SELECT field
    FROM table
    WHERE field2 IN (SELECT field3 FROM table2..etc

    i would like to alternate between th "IN" and "NOT IN"
    statement in the above based on the result of another
    field in another table

    can anyone help please

    regards Carlton
    carlton Guest

  2. #2

    Default switching between IN and NOT IN statements

    You can do it 2 ways:

    1) Dynamic sql (ugg)

    2)

    SELECT field
    FROM Table
    WHERE (field3=1 AND field2 IN (SELECT field3 FROM
    table2..etc)
    OR (field3=0 AND field2 NOT IN (SELECT field3 FROM
    table2..etc)

     
    mike Guest

  3. #3

    Default Re: switching between IN and NOT IN statements


    If I understand you correctly you cab look at
    WHERE NOT EXISTS on BOL

    "carlton" <com> wrote in message
    news:0d5801c36176$5bca0fb0$gbl... 


    Uri Guest

  4. #4

    Default Sorted Thanks All

     
    carlton Guest

Similar Threads

  1. If Statements????
    By ccarterca in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: October 17th, 12:34 PM
  2. SQL statements
    By news.working.it in forum Oracle Server
    Replies: 2
    Last Post: November 18th, 06:47 PM
  3. Switching between "IN" &"NOT IN" statements
    By Carlton in forum Microsoft SQL / MS SQL Server
    Replies: 3
    Last Post: August 13th, 05:22 PM
  4. IF, THEN, ELSE statements
    By Jeremy in forum Microsoft SQL / MS SQL Server
    Replies: 3
    Last Post: July 15th, 04:45 AM
  5. If/else statements - help.
    By Chris in forum PHP Development
    Replies: 1
    Last Post: June 28th, 01:55 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139