SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2000
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey guys, i'm just trying to sort this mysql query..
    what I want to do, is basically say:
    SELECT whatever, whatever FROM whatever WHERE whatever [IS NOT] whatever.

    ok, so I have tried:
    SELECT user, LEFT(usergbtitle,30) FROM userconfig LIMIT 4 WHERE user!='$user'

    This produces an error, thoguh.
    anyone have any ideas?
    Thanks.
    -aj

  2. #2
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Milton Keynes, UK
    Posts
    1,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is bit of a guess, but try:

    Code:
    SELECT user, LEFT(usergbtitle,30) FROM userconfig WHERE user <> '$user' LIMIT 4

  3. #3
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    != and <> are both valid "not equal to" operators in mySQL.

    The problem with with your statement is that LIMIT should come after WHERE.

    On a tangent here - but <> as an operator really bugs me! It is saying that "greater than or less than" is the same as "NOT equal to". But this doesn't make sence. If you have a value that is NULL how can you evaluate greater than NULL or less than NULL !?! Its like trying to work out what temperature it is inside a vacuum.

    <<edit>>

    BTW, if you are comparing strings then use STRCMP(expr1,expr2)

    WHERE STRCMP(user, '$user') != 0
    Last edited by freakysid; Mar 18, 2001 at 16:33.

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2000
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    god! course! what a stupid mistake!

    Thanks for the correction and the advice, guys.
    -aj


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
  •