Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    417
    Thanks
    168
    Thanked 1 Time in 1 Post

    how do 'does not equal' in mySQL?

    simple question, cant find the answer

    the error is at the end "WHERE id != 1037"

    all give errors:

    Code:
    SELECT id, headline, permalink, body, favico, author FROM anews_2_08 WHERE headline LIKE '% health %' OR headline LIKE '% war %' OR headline LIKE '% care %' OR headline LIKE '% clinton %' OR headline LIKE '% obama %' and WHERE NOT id = 1037 GROUP BY headline ORDER BY dateUnix DESC LIMIT 5
    Code:
    SELECT id, headline, permalink, body, favico, author FROM anews_2_08 WHERE headline LIKE '% health %' OR headline LIKE '% war %' OR headline LIKE '% care %' OR headline LIKE '% clinton %' OR headline LIKE '% obama %' and WHERE id != 1037 GROUP BY headline ORDER BY dateUnix DESC LIMIT 5
    Code:
    SELECT id, headline, permalink, body, favico, author FROM anews_2_08 WHERE headline LIKE '% health %' OR headline LIKE '% war %' OR headline LIKE '% care %' OR headline LIKE '% clinton %' OR headline LIKE '% obama %' and WHERE id <> 1037 GROUP BY headline ORDER BY dateUnix DESC LIMIT 5
    mySQL doesn't like my variations on WHERE id <> 1037 as this is where the error occurs.

    I even confirmed these variations in a google search.. so I must be doing something else incorrect
    Last edited by Bobafart; 02-01-2008 at 02:58 PM.

  • #2
    Regular Coder
    Join Date
    Dec 2006
    Posts
    417
    Thanks
    168
    Thanked 1 Time in 1 Post
    dumb me

    please ignore

    i used WHERE twice in my select


    silly me.. need more sleep

  • #3
    Banned
    Join Date
    Feb 2008
    Location
    Winnipeg, Canada
    Posts
    396
    Thanks
    0
    Thanked 29 Times in 29 Posts
    3 options:

    Code:
    SELECT * FROM table WHERE col <> val
    Code:
    SELECT * FROM table WHERE col != val
    Code:
    SELECT * FROM table WHERE NOT col =val
    oops, just saw that you noticed a typo - I'll post anyways for reference purposes

  • #4
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    I just wanted to note that:
    Code:
    &#37; text % != %text%  /* the first requires a preceding and trailing space while the second one does not*/
    I think you'll be safe for what you're doing I just wanted to chime in.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.


  •  

    Posting Permissions

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