manual.texi Added note about retrieving ENUM or SET column values

manual.texi	as numbers by adding +0 to the column name.
parent d7867b3a
...@@ -14145,11 +14145,18 @@ Lettercase is irrelevant when you assign values to an @code{ENUM} column. ...@@ -14145,11 +14145,18 @@ Lettercase is irrelevant when you assign values to an @code{ENUM} column.
However, values retrieved from the column later have lettercase matching the However, values retrieved from the column later have lettercase matching the
values that were used to specify the allowable values at table creation time. values that were used to specify the allowable values at table creation time.
If you retrieve an @code{ENUM} in a numeric context, the column value's index If you retrieve an @code{ENUM} in a numeric context, the column value's
is returned. If you store a number into an @code{ENUM}, the number is index is returned. For example, you can retrieve numeric values from
treated as an index, and the value stored is the enumeration member with an @code{ENUM} column like this:
that index. (However, this will not work with @code{LOAD DATA}, which treats
all input as strings.) @example
mysql> SELECT enum_col+0 FROM tbl_name;
@end example
If you store a number into an @code{ENUM}, the number is treated as an
index, and the value stored is the enumeration member with that index.
(However, this will not work with @code{LOAD DATA}, which treats all
input as strings.)
@code{ENUM} values are sorted according to the order in which the enumeration @code{ENUM} values are sorted according to the order in which the enumeration
members were listed in the column specification. (In other words, members were listed in the column specification. (In other words,
...@@ -14189,11 +14196,18 @@ A @code{SET} can have a maximum of 64 different members. ...@@ -14189,11 +14196,18 @@ A @code{SET} can have a maximum of 64 different members.
@strong{MySQL} stores @code{SET} values numerically, with the low-order bit @strong{MySQL} stores @code{SET} values numerically, with the low-order bit
of the stored value corresponding to the first set member. If you retrieve a of the stored value corresponding to the first set member. If you retrieve a
@code{SET} value in a numeric context, the value retrieved has bits set @code{SET} value in a numeric context, the value retrieved has bits set
corresponding to the set members that make up the column value. If a number corresponding to the set members that make up the column value. For example,
is stored into a @code{SET} column, the bits that are set in the binary you can retrieve numeric values from a @code{SET} column like this:
representation of the number determine the set members in the column value.
Suppose a column is specified as @code{SET("a","b","c","d")}. Then the @example
members have the following bit values: mysql> SELECT set_col+0 FROM tbl_name;
@end example
If a number is stored into a @code{SET} column, the bits that
are set in the binary representation of the number determine the
set members in the column value. Suppose a column is specified as
@code{SET("a","b","c","d")}. Then the members have the following bit
values:
@multitable @columnfractions .2 .2 .6 @multitable @columnfractions .2 .2 .6
@item @code{SET} @strong{member} @tab @strong{Decimal value} @tab @strong{Binary value} @item @code{SET} @strong{member} @tab @strong{Decimal value} @tab @strong{Binary value}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment