Relational operators are used for comparing numbers and strings. If a string is compared to a number, MySQL will try to convert the string to a number. If a TIMESTAMP column is compared to a string or a number, MySQL will attempt to convert the string or number to a timestamp value. If it's unsuccessful at converting the other value to a timestamp, it will convert the TIMESTAMP column's value to a string or a number. TIME and DATE columns are compared to other values as strings. The logical and relational operators allowed are listed in Table B-2.
The minus sign may be used for subtracting numbers or for setting a number to a negative. The equals sign is used to compare two values. If one is NULL, though, NULL will be returned. The <=> operator is used to compare for equality and it's NULL-safe. For example, an SQL statement containing something like IF(col1 <=> col2) where the values of both are NULL will return 1 and not NULL. |