Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2007
    Posts
    212

    Unanswered: mysql if statement evaluating int data type 0 to false?

    Hi

    I have a mysql stored procedure e.g:

    Code:
    CREATE PROCEDURE simpleproc (param1 INT)
    
    BEGIN
         IF param1 <> Null THEN
               #do something;
         END IF;
    END;
    If i call this procedure with param1 as 0 the if statement does nothing but works if param1 is of any other value other than 0. Why is the above statment evaluating param1 with a value of 0 as null?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    NULL is not equal to any value, and NULL is not unequal to any value, either

    try param IS NOT NULL
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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