PREPARE Statement Beginning with MySQL 8.0.22, a parameter used in a prepared statement has its type determined when the statement is first prepared, and retains this type whenever  EXECUTE  is invoked for this prepared statement (unless the statement is reprepared, as explained later in this section). Rules for determining a parameter’s type are listed here: •If a parameter is an argument of a function, the derived type depends on the function’s return type. •If a parameter is used as source for an assignment in a  SET  clause of an  UPDATE  statement or in the  ON DUPLICATE KEY UPDATE  clause of an  INSERT  statement, the derived type of the parameter is the type of the corresponding column which is updated by the  SET  or  ON DUPLICATE KEY UPDATE  clause. •If a parameter is an immediate member of a  SELECT  list that is part of an  INSERT  statement, the derived type of the parameter is the type of the corresponding column into which the parameter is inserted. •If a parameter is an immediate member of a  SELECT  list that is not part of an  INSERT  statement, the derived type of the parameter is  VARCHAR , and its collation is determined by the value of collation_connection . •A parameter which is the operand of a  CAST()  has the same type as specified by the  CAST() . •If the parameter is an operand of any of of  CASE ,  COALESCE() ,  IF , or  IFNULL , and has no type- determining context, the derived type for each of the parameters involved is  VARCHAR , and its collation is determined by the value of  collation_connection . •If all output operands of any of  CASE ,  COALESCE ,  IF ,  IFNULL , or  NULLIF  are parameters, or they are all NULL , the type of the parameter is decided by the context of the operator. •A parameter that is an output operand of any of  CASE ,  COALESCE ,  IF ,  IFNULL , or  NULLIF  has the same derived type as the aggregated type of the operator’s other output operands. •If all operands of a comparison operator are parameters, the derived type for each of them is  VARCHAR , with collation determined by the value of  collation_connection . •A parameter that is an operand of a ternary comparison operator such as  BETWEEN  has the same derived type as the aggregated type of the other operands. •A parameter which is an operand of a binary comparison operator has the same derived type as the other operand of the comparison. •A parameter which is an operand of a temporal operator has type  DATETIME  if the operator returns a DATETIME ,  TIME  if the operator returns a  TIME , and  DATE  if the operator returns a  DATE . •A parameter which is an operand of a character string operator has the same derived type as the aggregated type of the other operands. If all operands of the operator are parameters, the derived type is VARCHAR ; its collation is determined by the value of  collation_connection . •If an arithmetic operator has no type-determining context, the derived type for any parameters involved is  DOUBLE PRECISION . This can happen, for example, when the parameter is a top-level node in a SELECT  list, or when it is part of a comparison operator. •If a parameter is the operand of a unary arithmetic operator, the parameter’s type is decided by the context of the operator. •If both operands of a binary arithmetic operator are parameters, the type of the parameters is decided by the context of the operator. •A parameter which is an operand of a binary arithmetic operator has the same data type as the other operand. 2794