SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Nov 2001
    Location
    UK
    Posts
    553
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mySQL "NOT" Statement

    Is there a MySQL statement which is the equivelent of " !== " in PHP. I want to select everything UNLESS it has a particular ID number.

    Thanks,
    Regards, Ant.

  2. #2
    purple monkey dishwasher scoates's Avatar
    Join Date
    Nov 2001
    Location
    Montreal
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WHERE ID <> [the_excluded_id]

    <> to SQL is
    != to PHP

    S

  3. #3
    Database Jedi MattR's Avatar
    Join Date
    Jan 2001
    Location
    buried in the database shell (Washington, DC)
    Posts
    1,107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    != works as well although I think <> is the ANSI SQL standard way of NOT EQUAL TO.

  4. #4
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And if you really want the MySQL way to do !== I think it's IS NOT NULL.

  5. #5
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that's only to test if something's not NULL. it only compares a value to NULL. if you want to compare 2 non-NULL values, use =, <>, !=, or the NULL-safe version of =, <=>. e.g.

    Code:
    mysql> SELECT NULL=NULL;
    +-----------+
    | NULL=NULL |
    +-----------+
    |      NULL |
    +-----------+
    
    mysql> SELECT NULL<=>NULL;
    +-------------+
    | NULL<=>NULL |
    +-------------+
    |           1 |
    +-------------+
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR


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
  •