Type Conversion in Expression Evaluation mysql>  SELECT CONCAT(2,’ test’); -> ’2 test’ mysql>  SELECT 38.8, CAST(38.8 AS CHAR); -> 38.8, ’38.8’ mysql>  SELECT 38.8, CONCAT(38.8); -> 38.8, ’38.8’ It is also possible to convert a number to a string explicitly using the  CAST()  function. Conversion occurs implicitly with the  CONCAT()  function because it expects string arguments. See later in this section for information about the character set of implicit number-to-string conversions, and for modified rules that apply to  CREATE TABLE ... SELECT  statements. The following rules describe how conversion occurs for comparison operations: A single-row subquery from a table or tables is not considered a constant. For example, if a subquery returns an integer to be compared to a  DATETIME  value, the comparison is done as two integers. The integer is not converted to a temporal value. To compare the operands as  DATETIME  values, use CAST()  to explicitly convert the subquery value to  DATETIME . For information about conversion of values from one temporal type to another, see Section 11.2.7, “Conversion Between Date and Time Types” . Comparison of JSON values takes place at two levels. The first level of comparison is based on the JSON types of the compared values. If the types differ, the comparison result is determined solely by which type has higher precedence. If the two values have the same JSON type, a second level of comparison occurs using type-specific rules. For comparison of JSON and non-JSON values, the non-JSON value is converted to JSON and the values compared as JSON values. For details, see Comparison and Ordering of JSON Values. The following examples illustrate conversion of strings to numbers for comparison operations: mysql>  SELECT 1 > ’6x’; -> 0 mysql>  SELECT 7 > ’6x’; -> 1 •If one or both arguments are  NULL , the result of the comparison is  NULL , except for the  NULL -safe  <=> equality comparison operator. For  NULL <=> NULL , the result is true. No conversion is needed. •If both arguments in a comparison operation are strings, they are compared as strings. •If both arguments are integers, they are compared as integers. •Hexadecimal values are treated as binary strings if not compared to a number. •If one of the arguments is a  TIMESTAMP  or  DATETIME  column and the other argument is a constant, the constant is converted to a timestamp before the comparison is performed. This is done to be more ODBC-friendly. This is not done for the arguments to  IN() . To be safe, always use complete datetime, date, or time strings when doing comparisons. For example, to achieve best results when using  BETWEEN  with date or time values, use  CAST()  to explicitly convert the values to the desired data type. •If one of the arguments is a decimal value, comparison depends on the other argument. The arguments are compared as decimal values if the other argument is a decimal or integer value, or as floating-point values if the other argument is a floating-point value. •In all other cases, the arguments are compared as floating-point (real) numbers. For example, a comparison of string and numeric operands takes place as a comparison of floating-point numbers. 2120