COERCIBILITY( )

This MySQL function returns an arbirary value known as the coercibility of a given string or other item, determning how likely that item is to determine the collation used in an expression.

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

COERCIBILITY(string)

Explanation

This MySQL function returns an arbirary value known as the coercibility of a given string or other item, determning how likely that item is to determine the collation used in an expression. MySQL sometimes needs to choose which collation to use when results of an SQL statement involve different types of data. Possible return values from this function are:

  • 0
  • Collation has been explicitly specified (e.g., a statement using COLLATE).

  • 1
  • The argument merges values of different collations.

  • 2
  • The argument has an implicit collation (e.g., a column was given).

  • 3
  • The argument is a system constant, such as a system variable or a function that returns something similar.

  • 4
  • The argument is a literal string.

  • 5
  • The argument is NULL or an expression derived from a NULL value.

Lower coercibility levels take precedence over higher ones when the server is determining what collation to use. This function is available as of version 4.1.1 of MySQL.

Examples

Below is an example of this MySQL function:

SELECT COERCIBILITY('Geert')
AS 'His State';

+-----------+
| His State |
+-----------+
|         4 |
+-----------+