SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Value is not x number

    Hi all
    A quick one will this be OK to update vclass where vclass is NOT 1?
    Thanks just learning sql

    Code:
    UPDATE vehicle_type
       SET cylinders_id = 4
     WHERE vclass == 1 and cylinders <= 1499

  2. #2
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I get an sql error near "1" when updating any row that has cylinders of less than or equal to 1499 What is the catch please? Thanks
    UPDATE vehicle_type
    SET cylinders_id = 4
    WHERE vclass IS NOT 1 and cylinders <= 1499

  3. #3
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,039
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    Code MySQL:
    UPDATE
       vehicle_type
    SET
       cylinders_id = 4
    WHERE
       vclass != 1
       AND
       cylinders <= 1499
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  4. #4
    SitePoint Evangelist
    Join Date
    Mar 2008
    Posts
    551
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    suggest <> (standard hence portable) not != (mysql proprietary)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,039
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by r937 View Post
    suggest <> (standard hence portable) not != (mysql proprietary)
    I did look at the forum this thread is in before I posted my reply and decided it was safe to go with !=, but indeed, using <> as a general rule is better
    Thanks
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy


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
  •