Name

COERCIBILITY()

Synopsis

COERCIBILITY(string)

This function returns an arbitrary value known as the coercibility of a given string or other item, showing 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. Here are possible return values from this function:

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 is 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 which collation to use. This function is available as of version 4.1.1 of MySQL. Here is an example:

SELECT COERCIBILITY('Russell')
AS 'My State';

+----------+
| My State |
+----------+
|        4 |
+----------+

Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.