SQL multiple NOT LIKEs?

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default SQL multiple NOT LIKEs?

    How can I exclude multiple fields from a recordset with mySQL?

    After some googling, I found this working solution:

    SELECT *
    FROM customers
    WHERE customerID NOT LIKE '19'
    ORDER BY customerName ASC

    But what if I want to rule out customers no 19, 7 and 10?

    I have tried:

    WHERE customerID NOT LIKE '19,7 ,10'

    and a dozen different approaches to that. No good.


    Help greatly appreciated.

    Erik
    Erik Guest

  2. Similar Questions and Discussions

    1. Difficulties to send multiple object in multiple objectwith SOAP (WebService)
      Hi, I have a problem similar to this one: http://bugs.adobe.com/jira/browse/SDK-12891 I manage to send complex object from flex to web services...
    2. OT - as Linux gets more likes windows, windows gets more like Linux
      This assumed me, this is the command line for installing iis start /w pkgmgr /l:log.etw...
    3. Advanced OOP: Best OO design for rendering multiple page types to multiple devices
      Hoping to get some ideas from more experienced hands regarding the best way to use object-oriented design to assist my development of a content...
    4. IE 6.0 don't likes my Cookies!!
      The Script: <? if( isset($_POST) ) { setcookie("usr", $_POST, 0,'' ,'' , "0"); $_COOKIE = $_POST; // I just use this, because i need the...
    5. Who likes flashing with Canon ?
      " Miro" <miro01@hotmail.com> writes: Surely this isn't the Miro who only a few short months ago was decrying all flash work as garbage? Surely...
  3. #2

    Default Re: SQL multiple NOT LIKEs?

    Use the IN keyword.

    WHERE customerID NOT IN ('19,7 ,10')

    HTH
    Rob
    [url]http://robgt.com/[/url]


    RobGT Guest

  4. #3

    Default Re: SQL multiple NOT LIKEs?

    RobGT skrev:
    > Use the IN keyword.
    >
    > WHERE customerID NOT IN ('19,7 ,10')
    Thanx a bunch for the speedy response!

    Somehow I could not get this to work. It doesn't display any error
    message, but it doesn't rule out all the actual customers either, only
    the customer ID first in line.

    Example:

    WHERE customerID NOT IN ('5, 6, 7, 19, 20')

    Only ID #5 disappears from the list, leaving the rest still standing.

    What am I doing wrong?

    Erik

    Erik Guest

  5. #4

    Default Re: SQL multiple NOT LIKEs? PROBLEM SOLVED!

    OK, now it's working. I had to wrap every ID # in ''

    The correct recordset:

    SELECT *
    FROM kunder
    WHERE kundeID NOT IN ( '5', '6', '7', '19', '20 ' )

    Thanx to RobGT for lightning fast troubleshooting :)

    Erik
    Erik Guest

  6. #5

    Default Re: SQL multiple NOT LIKEs? PROBLEM SOLVED!

    Sorry about the incorrect syntax - glad you got it sorted!
    Now, where's that coffee!

    LOL
    Rob
    [url]http://robgt.com[/url]


    RobGT Guest

  7. #6

    Default Re: SQL multiple NOT LIKEs? PROBLEM SOLVED!

    .oO(Erik)
    >OK, now it's working. I had to wrap every ID # in ''
    Numeric values don't have to be quoted.
    >The correct recordset:
    >
    >SELECT *
    >FROM kunder
    >WHERE kundeID NOT IN ( '5', '6', '7', '19', '20 ' )
    ....
    WHERE kundeID NOT IN (5, 6, 7, 19, 20)

    Micha
    Michael Fesser Guest

  8. #7

    Default Re: SQL multiple NOT LIKEs? PROBLEM SOLVED!

    Michael Fesser skrev:
    >
    > Numeric values don't have to be quoted.
    Even better! Thx a lot! :)

    Erik
    Erik Guest

  9. #8

    Thumbs up Re: SQL multiple NOT LIKEs?

    Try this Query it's give best result


    select * from [Item Code] not like '1' and [Item Code] not like '2' and [item code] not like '3'


    Dora Babu M
    Exertion Tech. PVT,.LTD.
    Chennai.
    dora babu M Guest

Posting Permissions

  • You may not post new threads
  • You may 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