SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    698
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Select Where Not In Like ()

    I need to be able to select the count of all values in a table that are not in a group of values, only I need to be able to use wildcards, so effectively I need to be able to merge LIKE and IN functions to something like this:

    Code MySQL:
    SELECT count(*)
    FROM tbl_name
    WHERE col1 NOT LIKE IN ('val1%', 'val2%');

    Is there a way to do this, and if so, how?

    Thanks

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Code MySQL:
    SELECT count(*)
    FROM tbl_name
    WHERE col1 NOT LIKE 'val1%'
    AND   col1 NOT LIKE 'val2%';

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    England
    Posts
    698
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yeah, can do it that way, just seemed like I would be taking ages adding extra AND lines, when I've been trying to get away from using AND for things like this. If there's no alternative then of course that will be the way I'll go with it


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
  •