Author: jstephens
Date: 2010-11-12 20:25:37 +0100 (Fri, 12 Nov 2010)
New Revision: 23721
Log:
Add assignment operator opfunctions entries and corresponding subsection in functions-core
Fixes Docs BUG#58144
Modified:
trunk/dynamic-docs/opsfunctions/opfunctions.xml
trunk/refman-4.1/functions-core.xml
trunk/refman-5.0/functions-core.xml
trunk/refman-5.1/functions-core.xml
trunk/refman-5.5/functions-core.xml
trunk/refman-5.6/functions-core.xml
trunk/refman-6.0/functions-core.xml
Modified: trunk/dynamic-docs/opsfunctions/opfunctions.xml
===================================================================
--- trunk/dynamic-docs/opsfunctions/opfunctions.xml 2010-11-12 18:53:21 UTC (rev 23720)
+++ trunk/dynamic-docs/opsfunctions/opfunctions.xml 2010-11-12 19:25:37 UTC (rev 23721)
Changed blocks: 1, Lines Added: 45, Lines Deleted: 0; 1499 bytes
@@ -7894,5 +7894,50 @@
</versions>
</opfunction>
+ <opfunction id="assign-value" class="assignment" type="operator">
+ <display>:=</display>
+
+ <description>Assign a value</description>
+
+ <versions>
+ <manual version="4.0"/>
+ <manual version="4.1"/>
+ <manual version="5.0"/>
+ <manual version="5.1"/>
+ <manual version="5.2"/>
+ <manual version="5.4"/>
+ <manual version="5.5"/>
+ <manual version="5.6"/>
+ <manual version="6.0"/>
+ </versions>
+
+ </opfunction>
+ <opfunction id="assign-equal" class="assignment" type="operator">
+
+ <display>=</display>
+
+ <description>
+
+<![CDATA[Assign a value (as part of a
+<literal role="stmt" condition="set-option">SET</literal> statement, or
+as part of the <literal>SET</literal> clause in an
+<literal role="stmt">UPDATE</literal> statement)]]>
+
+ </description>
+
+ <versions>
+ <manual version="4.0"/>
+ <manual version="4.1"/>
+ <manual version="5.0"/>
+ <manual version="5.1"/>
+ <manual version="5.2"/>
+ <manual version="5.4"/>
+ <manual version="5.5"/>
+ <manual version="5.6"/>
+ <manual version="6.0"/>
+ </versions>
+
+ </opfunction>
+
</opfunctions>
Modified: trunk/refman-4.1/functions-core.xml
===================================================================
--- trunk/refman-4.1/functions-core.xml 2010-11-12 18:53:21 UTC (rev 23720)
+++ trunk/refman-4.1/functions-core.xml 2010-11-12 19:25:37 UTC (rev 23721)
Changed blocks: 1, Lines Added: 218, Lines Deleted: 0; 8047 bytes
@@ -1754,6 +1754,224 @@
</section>
+ <section id="assignment-operators">
+
+ <title>Assignment Operators</title>
+
+ <indexterm>
+ <primary>assignment operators</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>operators</primary>
+ <secondary>assignment</secondary>
+ </indexterm>
+
+ <para condition="dynamic:opfuncs:fullsummary" role="5.1::assignment">
+ <citetitle>Assignment Operators</citetitle>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <remark role="help-topic" condition="assign-value"/>
+
+ <remark role="help-syntax-begin"/>
+
+ <para id="operator_assign-value">
+ <indexterm>
+ <primary>:= (assignment operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>assignment operator</primary>
+ <secondary>:=</secondary>
+ </indexterm>
+
+ <literal role="op" condition="assign-value">:=</literal>
+ </para>
+
+ <remark role="help-syntax-end"/>
+
+ <remark role="help-description-begin"/>
+
+ <para>
+ Assignment operator. Causes the user variable on the left
+ hand side of the operator to take on the value to its right.
+ The value on the right hand side may be a literal value,
+ another variable storing a value, or any legal expression
+ that yields a scalar value, including the result of a query
+ (provided that this value is a scalar value). You can
+ perform multiple assignments in the same
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement. You can perform multiple assignments in the same
+ statement-
+ </para>
+
+ <para>
+ Unlike
+ <literal role="op" condition="assign-equal">=</literal>, the
+ <literal role="op" condition="assign-value">:=</literal>
+ operator is never interpreted as a comparison operator. This
+ means you can use
+ <literal role="op" condition="assign-value">:=</literal> in
+ any valid SQL statement (not just in
+ <literal role="stmt" condition="set-option">SET</literal>
+ statements) to assign a value to a variable.
+ </para>
+
+ <remark role="help-description-end"/>
+
+ <remark role="help-example"/>
+
+<programlisting>
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> NULL, NULL
+mysql> <userinput>SELECT @var1 := 1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2 := @var1;</userinput>
+ -> 1, 1
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, 1
+
+mysql> <userinput>SELECT @var1:=COUNT(*) FROM t1;</userinput>
+ -> 4
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 4
+</programlisting>
+
+ <para>
+ You can make value assignments using
+ <literal role="op" condition="assign-value">:=</literal> in
+ other statements besides
+ <literal role="stmt">SELECT</literal>, such as
+ <literal role="stmt">UPDATE</literal>, as shown here:
+ </para>
+
+<programlisting>
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 4
+mysql> <userinput>SELECT * FROM t1;</userinput>
+ -> 1, 3, 5, 7
+
+mysql> <userinput>UPDATE t1 SET c1 = 2 WHERE c1 = @var1:= 1;</userinput>
+Query OK, 1 row affected (0.00 sec)
+Rows matched: 1 Changed: 1 Warnings: 0
+
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 1
+mysql> <userinput>SELECT * FROM t1;</userinput>
+ -> 2, 3, 5, 7
+</programlisting>
+
+ <para>
+ While it is also possible both to set and to read the value
+ of the same variable in a single SQL statement using the
+ <literal role="op" condition="assign-value">:=</literal>
+ operator, this is not recommended.
+ <xref linkend="user-variables"/>, explains why you should
+ avoid doing this.
+ </para>
+ </listitem>
+
+ <listitem>
+ <remark role="help-topic" condition="assign-equal"/>
+
+ <remark role="help-syntax-begin"/>
+
+ <para id="operator_assign-equal">
+ <indexterm>
+ <primary>= (assignment operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>assignment operator</primary>
+ <secondary>=</secondary>
+ </indexterm>
+
+ <indexterm>
+ <primary>SET statement</primary>
+ <secondary>assignment operator</secondary>
+ </indexterm>
+
+ <literal role="op" condition="assign-value">:=</literal>
+ </para>
+
+ <remark role="help-syntax-end"/>
+
+ <remark role="help-description-begin"/>
+
+ <para>
+ This operator is used to perform value assignments in two
+ cases, described in the next two paragraphs.
+ </para>
+
+ <para>
+ Within a
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement, <literal>=</literal> is treated as an assignment
+ operator that causes the user variable on the left hand side
+ of the operator to take on the value to its right. (In other
+ words, when used in a
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement, <literal>=</literal> is treated identically to
+ <literal role="op" condition="assign-value">:=</literal>.)
+ The value on the right hand side may be a literal value,
+ another variable storing a value, or any legal expression
+ that yields a scalar value, including the result of a query
+ (provided that this value is a scalar value). You can
+ perform multiple assignments in the same
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement.
+ </para>
+
+ <para>
+ In the <literal>SET</literal> clause of an
+ <literal role="stmt">UPDATE</literal> statement,
+ <literal>=</literal> also acts as an assignment operator; in
+ this case, however, it causes the column named on the left
+ hand side of the operator to assume the value given to the
+ right, provided any <literal>WHERE</literal> conditions that
+ are part of the <literal role="stmt">UPDATE</literal> are
+ met. You can make multiple assignments in the same
+ <literal>SET</literal> clause of an
+ <literal role="stmt">UPDATE</literal> statement.
+ </para>
+
+ <para>
+ In any other context, <literal>=</literal> is treated as a
+ <link linkend="operator_equal">comparison operator</link>.
+ </para>
+
+ <remark role="help-description-end"/>
+
+ <remark role="help-example"/>
+
+<programlisting>
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> NULL, NULL
+mysql> <userinput>SELECT @var1 := 1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2 := @var1;</userinput>
+ -> 1, 1
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, 1
+</programlisting>
+
+ <para>
+ For more information, see <xref linkend="set-option"/>,
+ <xref linkend="update"/>, and <xref linkend="subqueries"/>.
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ </section>
+
</section>
<section id="control-flow-functions">
Modified: trunk/refman-5.0/functions-core.xml
===================================================================
--- trunk/refman-5.0/functions-core.xml 2010-11-12 18:53:21 UTC (rev 23720)
+++ trunk/refman-5.0/functions-core.xml 2010-11-12 19:25:37 UTC (rev 23721)
Changed blocks: 1, Lines Added: 218, Lines Deleted: 0; 8047 bytes
@@ -1869,6 +1869,224 @@
</section>
+ <section id="assignment-operators">
+
+ <title>Assignment Operators</title>
+
+ <indexterm>
+ <primary>assignment operators</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>operators</primary>
+ <secondary>assignment</secondary>
+ </indexterm>
+
+ <para condition="dynamic:opfuncs:fullsummary" role="5.1::assignment">
+ <citetitle>Assignment Operators</citetitle>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <remark role="help-topic" condition="assign-value"/>
+
+ <remark role="help-syntax-begin"/>
+
+ <para id="operator_assign-value">
+ <indexterm>
+ <primary>:= (assignment operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>assignment operator</primary>
+ <secondary>:=</secondary>
+ </indexterm>
+
+ <literal role="op" condition="assign-value">:=</literal>
+ </para>
+
+ <remark role="help-syntax-end"/>
+
+ <remark role="help-description-begin"/>
+
+ <para>
+ Assignment operator. Causes the user variable on the left
+ hand side of the operator to take on the value to its right.
+ The value on the right hand side may be a literal value,
+ another variable storing a value, or any legal expression
+ that yields a scalar value, including the result of a query
+ (provided that this value is a scalar value). You can
+ perform multiple assignments in the same
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement. You can perform multiple assignments in the same
+ statement-
+ </para>
+
+ <para>
+ Unlike
+ <literal role="op" condition="assign-equal">=</literal>, the
+ <literal role="op" condition="assign-value">:=</literal>
+ operator is never interpreted as a comparison operator. This
+ means you can use
+ <literal role="op" condition="assign-value">:=</literal> in
+ any valid SQL statement (not just in
+ <literal role="stmt" condition="set-option">SET</literal>
+ statements) to assign a value to a variable.
+ </para>
+
+ <remark role="help-description-end"/>
+
+ <remark role="help-example"/>
+
+<programlisting>
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> NULL, NULL
+mysql> <userinput>SELECT @var1 := 1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2 := @var1;</userinput>
+ -> 1, 1
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, 1
+
+mysql> <userinput>SELECT @var1:=COUNT(*) FROM t1;</userinput>
+ -> 4
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 4
+</programlisting>
+
+ <para>
+ You can make value assignments using
+ <literal role="op" condition="assign-value">:=</literal> in
+ other statements besides
+ <literal role="stmt">SELECT</literal>, such as
+ <literal role="stmt">UPDATE</literal>, as shown here:
+ </para>
+
+<programlisting>
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 4
+mysql> <userinput>SELECT * FROM t1;</userinput>
+ -> 1, 3, 5, 7
+
+mysql> <userinput>UPDATE t1 SET c1 = 2 WHERE c1 = @var1:= 1;</userinput>
+Query OK, 1 row affected (0.00 sec)
+Rows matched: 1 Changed: 1 Warnings: 0
+
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 1
+mysql> <userinput>SELECT * FROM t1;</userinput>
+ -> 2, 3, 5, 7
+</programlisting>
+
+ <para>
+ While it is also possible both to set and to read the value
+ of the same variable in a single SQL statement using the
+ <literal role="op" condition="assign-value">:=</literal>
+ operator, this is not recommended.
+ <xref linkend="user-variables"/>, explains why you should
+ avoid doing this.
+ </para>
+ </listitem>
+
+ <listitem>
+ <remark role="help-topic" condition="assign-equal"/>
+
+ <remark role="help-syntax-begin"/>
+
+ <para id="operator_assign-equal">
+ <indexterm>
+ <primary>= (assignment operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>assignment operator</primary>
+ <secondary>=</secondary>
+ </indexterm>
+
+ <indexterm>
+ <primary>SET statement</primary>
+ <secondary>assignment operator</secondary>
+ </indexterm>
+
+ <literal role="op" condition="assign-value">:=</literal>
+ </para>
+
+ <remark role="help-syntax-end"/>
+
+ <remark role="help-description-begin"/>
+
+ <para>
+ This operator is used to perform value assignments in two
+ cases, described in the next two paragraphs.
+ </para>
+
+ <para>
+ Within a
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement, <literal>=</literal> is treated as an assignment
+ operator that causes the user variable on the left hand side
+ of the operator to take on the value to its right. (In other
+ words, when used in a
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement, <literal>=</literal> is treated identically to
+ <literal role="op" condition="assign-value">:=</literal>.)
+ The value on the right hand side may be a literal value,
+ another variable storing a value, or any legal expression
+ that yields a scalar value, including the result of a query
+ (provided that this value is a scalar value). You can
+ perform multiple assignments in the same
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement.
+ </para>
+
+ <para>
+ In the <literal>SET</literal> clause of an
+ <literal role="stmt">UPDATE</literal> statement,
+ <literal>=</literal> also acts as an assignment operator; in
+ this case, however, it causes the column named on the left
+ hand side of the operator to assume the value given to the
+ right, provided any <literal>WHERE</literal> conditions that
+ are part of the <literal role="stmt">UPDATE</literal> are
+ met. You can make multiple assignments in the same
+ <literal>SET</literal> clause of an
+ <literal role="stmt">UPDATE</literal> statement.
+ </para>
+
+ <para>
+ In any other context, <literal>=</literal> is treated as a
+ <link linkend="operator_equal">comparison operator</link>.
+ </para>
+
+ <remark role="help-description-end"/>
+
+ <remark role="help-example"/>
+
+<programlisting>
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> NULL, NULL
+mysql> <userinput>SELECT @var1 := 1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2 := @var1;</userinput>
+ -> 1, 1
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, 1
+</programlisting>
+
+ <para>
+ For more information, see <xref linkend="set-option"/>,
+ <xref linkend="update"/>, and <xref linkend="subqueries"/>.
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ </section>
+
</section>
<section id="control-flow-functions">
Modified: trunk/refman-5.1/functions-core.xml
===================================================================
--- trunk/refman-5.1/functions-core.xml 2010-11-12 18:53:21 UTC (rev 23720)
+++ trunk/refman-5.1/functions-core.xml 2010-11-12 19:25:37 UTC (rev 23721)
Changed blocks: 1, Lines Added: 218, Lines Deleted: 0; 8047 bytes
@@ -1847,6 +1847,224 @@
</section>
+ <section id="assignment-operators">
+
+ <title>Assignment Operators</title>
+
+ <indexterm>
+ <primary>assignment operators</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>operators</primary>
+ <secondary>assignment</secondary>
+ </indexterm>
+
+ <para condition="dynamic:opfuncs:fullsummary" role="5.1::assignment">
+ <citetitle>Assignment Operators</citetitle>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <remark role="help-topic" condition="assign-value"/>
+
+ <remark role="help-syntax-begin"/>
+
+ <para id="operator_assign-value">
+ <indexterm>
+ <primary>:= (assignment operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>assignment operator</primary>
+ <secondary>:=</secondary>
+ </indexterm>
+
+ <literal role="op" condition="assign-value">:=</literal>
+ </para>
+
+ <remark role="help-syntax-end"/>
+
+ <remark role="help-description-begin"/>
+
+ <para>
+ Assignment operator. Causes the user variable on the left
+ hand side of the operator to take on the value to its right.
+ The value on the right hand side may be a literal value,
+ another variable storing a value, or any legal expression
+ that yields a scalar value, including the result of a query
+ (provided that this value is a scalar value). You can
+ perform multiple assignments in the same
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement. You can perform multiple assignments in the same
+ statement-
+ </para>
+
+ <para>
+ Unlike
+ <literal role="op" condition="assign-equal">=</literal>, the
+ <literal role="op" condition="assign-value">:=</literal>
+ operator is never interpreted as a comparison operator. This
+ means you can use
+ <literal role="op" condition="assign-value">:=</literal> in
+ any valid SQL statement (not just in
+ <literal role="stmt" condition="set-option">SET</literal>
+ statements) to assign a value to a variable.
+ </para>
+
+ <remark role="help-description-end"/>
+
+ <remark role="help-example"/>
+
+<programlisting>
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> NULL, NULL
+mysql> <userinput>SELECT @var1 := 1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2 := @var1;</userinput>
+ -> 1, 1
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, 1
+
+mysql> <userinput>SELECT @var1:=COUNT(*) FROM t1;</userinput>
+ -> 4
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 4
+</programlisting>
+
+ <para>
+ You can make value assignments using
+ <literal role="op" condition="assign-value">:=</literal> in
+ other statements besides
+ <literal role="stmt">SELECT</literal>, such as
+ <literal role="stmt">UPDATE</literal>, as shown here:
+ </para>
+
+<programlisting>
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 4
+mysql> <userinput>SELECT * FROM t1;</userinput>
+ -> 1, 3, 5, 7
+
+mysql> <userinput>UPDATE t1 SET c1 = 2 WHERE c1 = @var1:= 1;</userinput>
+Query OK, 1 row affected (0.00 sec)
+Rows matched: 1 Changed: 1 Warnings: 0
+
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 1
+mysql> <userinput>SELECT * FROM t1;</userinput>
+ -> 2, 3, 5, 7
+</programlisting>
+
+ <para>
+ While it is also possible both to set and to read the value
+ of the same variable in a single SQL statement using the
+ <literal role="op" condition="assign-value">:=</literal>
+ operator, this is not recommended.
+ <xref linkend="user-variables"/>, explains why you should
+ avoid doing this.
+ </para>
+ </listitem>
+
+ <listitem>
+ <remark role="help-topic" condition="assign-equal"/>
+
+ <remark role="help-syntax-begin"/>
+
+ <para id="operator_assign-equal">
+ <indexterm>
+ <primary>= (assignment operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>assignment operator</primary>
+ <secondary>=</secondary>
+ </indexterm>
+
+ <indexterm>
+ <primary>SET statement</primary>
+ <secondary>assignment operator</secondary>
+ </indexterm>
+
+ <literal role="op" condition="assign-value">:=</literal>
+ </para>
+
+ <remark role="help-syntax-end"/>
+
+ <remark role="help-description-begin"/>
+
+ <para>
+ This operator is used to perform value assignments in two
+ cases, described in the next two paragraphs.
+ </para>
+
+ <para>
+ Within a
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement, <literal>=</literal> is treated as an assignment
+ operator that causes the user variable on the left hand side
+ of the operator to take on the value to its right. (In other
+ words, when used in a
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement, <literal>=</literal> is treated identically to
+ <literal role="op" condition="assign-value">:=</literal>.)
+ The value on the right hand side may be a literal value,
+ another variable storing a value, or any legal expression
+ that yields a scalar value, including the result of a query
+ (provided that this value is a scalar value). You can
+ perform multiple assignments in the same
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement.
+ </para>
+
+ <para>
+ In the <literal>SET</literal> clause of an
+ <literal role="stmt">UPDATE</literal> statement,
+ <literal>=</literal> also acts as an assignment operator; in
+ this case, however, it causes the column named on the left
+ hand side of the operator to assume the value given to the
+ right, provided any <literal>WHERE</literal> conditions that
+ are part of the <literal role="stmt">UPDATE</literal> are
+ met. You can make multiple assignments in the same
+ <literal>SET</literal> clause of an
+ <literal role="stmt">UPDATE</literal> statement.
+ </para>
+
+ <para>
+ In any other context, <literal>=</literal> is treated as a
+ <link linkend="operator_equal">comparison operator</link>.
+ </para>
+
+ <remark role="help-description-end"/>
+
+ <remark role="help-example"/>
+
+<programlisting>
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> NULL, NULL
+mysql> <userinput>SELECT @var1 := 1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2 := @var1;</userinput>
+ -> 1, 1
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, 1
+</programlisting>
+
+ <para>
+ For more information, see <xref linkend="set-option"/>,
+ <xref linkend="update"/>, and <xref linkend="subqueries"/>.
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ </section>
+
</section>
<section id="control-flow-functions">
Modified: trunk/refman-5.5/functions-core.xml
===================================================================
--- trunk/refman-5.5/functions-core.xml 2010-11-12 18:53:21 UTC (rev 23720)
+++ trunk/refman-5.5/functions-core.xml 2010-11-12 19:25:37 UTC (rev 23721)
Changed blocks: 1, Lines Added: 218, Lines Deleted: 0; 8047 bytes
@@ -2018,6 +2018,224 @@
</section>
+ <section id="assignment-operators">
+
+ <title>Assignment Operators</title>
+
+ <indexterm>
+ <primary>assignment operators</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>operators</primary>
+ <secondary>assignment</secondary>
+ </indexterm>
+
+ <para condition="dynamic:opfuncs:fullsummary" role="5.1::assignment">
+ <citetitle>Assignment Operators</citetitle>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <remark role="help-topic" condition="assign-value"/>
+
+ <remark role="help-syntax-begin"/>
+
+ <para id="operator_assign-value">
+ <indexterm>
+ <primary>:= (assignment operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>assignment operator</primary>
+ <secondary>:=</secondary>
+ </indexterm>
+
+ <literal role="op" condition="assign-value">:=</literal>
+ </para>
+
+ <remark role="help-syntax-end"/>
+
+ <remark role="help-description-begin"/>
+
+ <para>
+ Assignment operator. Causes the user variable on the left
+ hand side of the operator to take on the value to its right.
+ The value on the right hand side may be a literal value,
+ another variable storing a value, or any legal expression
+ that yields a scalar value, including the result of a query
+ (provided that this value is a scalar value). You can
+ perform multiple assignments in the same
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement. You can perform multiple assignments in the same
+ statement-
+ </para>
+
+ <para>
+ Unlike
+ <literal role="op" condition="assign-equal">=</literal>, the
+ <literal role="op" condition="assign-value">:=</literal>
+ operator is never interpreted as a comparison operator. This
+ means you can use
+ <literal role="op" condition="assign-value">:=</literal> in
+ any valid SQL statement (not just in
+ <literal role="stmt" condition="set-option">SET</literal>
+ statements) to assign a value to a variable.
+ </para>
+
+ <remark role="help-description-end"/>
+
+ <remark role="help-example"/>
+
+<programlisting>
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> NULL, NULL
+mysql> <userinput>SELECT @var1 := 1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2 := @var1;</userinput>
+ -> 1, 1
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, 1
+
+mysql> <userinput>SELECT @var1:=COUNT(*) FROM t1;</userinput>
+ -> 4
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 4
+</programlisting>
+
+ <para>
+ You can make value assignments using
+ <literal role="op" condition="assign-value">:=</literal> in
+ other statements besides
+ <literal role="stmt">SELECT</literal>, such as
+ <literal role="stmt">UPDATE</literal>, as shown here:
+ </para>
+
+<programlisting>
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 4
+mysql> <userinput>SELECT * FROM t1;</userinput>
+ -> 1, 3, 5, 7
+
+mysql> <userinput>UPDATE t1 SET c1 = 2 WHERE c1 = @var1:= 1;</userinput>
+Query OK, 1 row affected (0.00 sec)
+Rows matched: 1 Changed: 1 Warnings: 0
+
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 1
+mysql> <userinput>SELECT * FROM t1;</userinput>
+ -> 2, 3, 5, 7
+</programlisting>
+
+ <para>
+ While it is also possible both to set and to read the value
+ of the same variable in a single SQL statement using the
+ <literal role="op" condition="assign-value">:=</literal>
+ operator, this is not recommended.
+ <xref linkend="user-variables"/>, explains why you should
+ avoid doing this.
+ </para>
+ </listitem>
+
+ <listitem>
+ <remark role="help-topic" condition="assign-equal"/>
+
+ <remark role="help-syntax-begin"/>
+
+ <para id="operator_assign-equal">
+ <indexterm>
+ <primary>= (assignment operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>assignment operator</primary>
+ <secondary>=</secondary>
+ </indexterm>
+
+ <indexterm>
+ <primary>SET statement</primary>
+ <secondary>assignment operator</secondary>
+ </indexterm>
+
+ <literal role="op" condition="assign-value">:=</literal>
+ </para>
+
+ <remark role="help-syntax-end"/>
+
+ <remark role="help-description-begin"/>
+
+ <para>
+ This operator is used to perform value assignments in two
+ cases, described in the next two paragraphs.
+ </para>
+
+ <para>
+ Within a
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement, <literal>=</literal> is treated as an assignment
+ operator that causes the user variable on the left hand side
+ of the operator to take on the value to its right. (In other
+ words, when used in a
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement, <literal>=</literal> is treated identically to
+ <literal role="op" condition="assign-value">:=</literal>.)
+ The value on the right hand side may be a literal value,
+ another variable storing a value, or any legal expression
+ that yields a scalar value, including the result of a query
+ (provided that this value is a scalar value). You can
+ perform multiple assignments in the same
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement.
+ </para>
+
+ <para>
+ In the <literal>SET</literal> clause of an
+ <literal role="stmt">UPDATE</literal> statement,
+ <literal>=</literal> also acts as an assignment operator; in
+ this case, however, it causes the column named on the left
+ hand side of the operator to assume the value given to the
+ right, provided any <literal>WHERE</literal> conditions that
+ are part of the <literal role="stmt">UPDATE</literal> are
+ met. You can make multiple assignments in the same
+ <literal>SET</literal> clause of an
+ <literal role="stmt">UPDATE</literal> statement.
+ </para>
+
+ <para>
+ In any other context, <literal>=</literal> is treated as a
+ <link linkend="operator_equal">comparison operator</link>.
+ </para>
+
+ <remark role="help-description-end"/>
+
+ <remark role="help-example"/>
+
+<programlisting>
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> NULL, NULL
+mysql> <userinput>SELECT @var1 := 1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2 := @var1;</userinput>
+ -> 1, 1
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, 1
+</programlisting>
+
+ <para>
+ For more information, see <xref linkend="set-option"/>,
+ <xref linkend="update"/>, and <xref linkend="subqueries"/>.
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ </section>
+
</section>
<section id="control-flow-functions">
Modified: trunk/refman-5.6/functions-core.xml
===================================================================
--- trunk/refman-5.6/functions-core.xml 2010-11-12 18:53:21 UTC (rev 23720)
+++ trunk/refman-5.6/functions-core.xml 2010-11-12 19:25:37 UTC (rev 23721)
Changed blocks: 1, Lines Added: 218, Lines Deleted: 0; 8047 bytes
@@ -1964,6 +1964,224 @@
</section>
+ <section id="assignment-operators">
+
+ <title>Assignment Operators</title>
+
+ <indexterm>
+ <primary>assignment operators</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>operators</primary>
+ <secondary>assignment</secondary>
+ </indexterm>
+
+ <para condition="dynamic:opfuncs:fullsummary" role="5.1::assignment">
+ <citetitle>Assignment Operators</citetitle>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <remark role="help-topic" condition="assign-value"/>
+
+ <remark role="help-syntax-begin"/>
+
+ <para id="operator_assign-value">
+ <indexterm>
+ <primary>:= (assignment operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>assignment operator</primary>
+ <secondary>:=</secondary>
+ </indexterm>
+
+ <literal role="op" condition="assign-value">:=</literal>
+ </para>
+
+ <remark role="help-syntax-end"/>
+
+ <remark role="help-description-begin"/>
+
+ <para>
+ Assignment operator. Causes the user variable on the left
+ hand side of the operator to take on the value to its right.
+ The value on the right hand side may be a literal value,
+ another variable storing a value, or any legal expression
+ that yields a scalar value, including the result of a query
+ (provided that this value is a scalar value). You can
+ perform multiple assignments in the same
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement. You can perform multiple assignments in the same
+ statement-
+ </para>
+
+ <para>
+ Unlike
+ <literal role="op" condition="assign-equal">=</literal>, the
+ <literal role="op" condition="assign-value">:=</literal>
+ operator is never interpreted as a comparison operator. This
+ means you can use
+ <literal role="op" condition="assign-value">:=</literal> in
+ any valid SQL statement (not just in
+ <literal role="stmt" condition="set-option">SET</literal>
+ statements) to assign a value to a variable.
+ </para>
+
+ <remark role="help-description-end"/>
+
+ <remark role="help-example"/>
+
+<programlisting>
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> NULL, NULL
+mysql> <userinput>SELECT @var1 := 1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2 := @var1;</userinput>
+ -> 1, 1
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, 1
+
+mysql> <userinput>SELECT @var1:=COUNT(*) FROM t1;</userinput>
+ -> 4
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 4
+</programlisting>
+
+ <para>
+ You can make value assignments using
+ <literal role="op" condition="assign-value">:=</literal> in
+ other statements besides
+ <literal role="stmt">SELECT</literal>, such as
+ <literal role="stmt">UPDATE</literal>, as shown here:
+ </para>
+
+<programlisting>
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 4
+mysql> <userinput>SELECT * FROM t1;</userinput>
+ -> 1, 3, 5, 7
+
+mysql> <userinput>UPDATE t1 SET c1 = 2 WHERE c1 = @var1:= 1;</userinput>
+Query OK, 1 row affected (0.00 sec)
+Rows matched: 1 Changed: 1 Warnings: 0
+
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 1
+mysql> <userinput>SELECT * FROM t1;</userinput>
+ -> 2, 3, 5, 7
+</programlisting>
+
+ <para>
+ While it is also possible both to set and to read the value
+ of the same variable in a single SQL statement using the
+ <literal role="op" condition="assign-value">:=</literal>
+ operator, this is not recommended.
+ <xref linkend="user-variables"/>, explains why you should
+ avoid doing this.
+ </para>
+ </listitem>
+
+ <listitem>
+ <remark role="help-topic" condition="assign-equal"/>
+
+ <remark role="help-syntax-begin"/>
+
+ <para id="operator_assign-equal">
+ <indexterm>
+ <primary>= (assignment operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>assignment operator</primary>
+ <secondary>=</secondary>
+ </indexterm>
+
+ <indexterm>
+ <primary>SET statement</primary>
+ <secondary>assignment operator</secondary>
+ </indexterm>
+
+ <literal role="op" condition="assign-value">:=</literal>
+ </para>
+
+ <remark role="help-syntax-end"/>
+
+ <remark role="help-description-begin"/>
+
+ <para>
+ This operator is used to perform value assignments in two
+ cases, described in the next two paragraphs.
+ </para>
+
+ <para>
+ Within a
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement, <literal>=</literal> is treated as an assignment
+ operator that causes the user variable on the left hand side
+ of the operator to take on the value to its right. (In other
+ words, when used in a
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement, <literal>=</literal> is treated identically to
+ <literal role="op" condition="assign-value">:=</literal>.)
+ The value on the right hand side may be a literal value,
+ another variable storing a value, or any legal expression
+ that yields a scalar value, including the result of a query
+ (provided that this value is a scalar value). You can
+ perform multiple assignments in the same
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement.
+ </para>
+
+ <para>
+ In the <literal>SET</literal> clause of an
+ <literal role="stmt">UPDATE</literal> statement,
+ <literal>=</literal> also acts as an assignment operator; in
+ this case, however, it causes the column named on the left
+ hand side of the operator to assume the value given to the
+ right, provided any <literal>WHERE</literal> conditions that
+ are part of the <literal role="stmt">UPDATE</literal> are
+ met. You can make multiple assignments in the same
+ <literal>SET</literal> clause of an
+ <literal role="stmt">UPDATE</literal> statement.
+ </para>
+
+ <para>
+ In any other context, <literal>=</literal> is treated as a
+ <link linkend="operator_equal">comparison operator</link>.
+ </para>
+
+ <remark role="help-description-end"/>
+
+ <remark role="help-example"/>
+
+<programlisting>
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> NULL, NULL
+mysql> <userinput>SELECT @var1 := 1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2 := @var1;</userinput>
+ -> 1, 1
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, 1
+</programlisting>
+
+ <para>
+ For more information, see <xref linkend="set-option"/>,
+ <xref linkend="update"/>, and <xref linkend="subqueries"/>.
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ </section>
+
</section>
<section id="control-flow-functions">
Modified: trunk/refman-6.0/functions-core.xml
===================================================================
--- trunk/refman-6.0/functions-core.xml 2010-11-12 18:53:21 UTC (rev 23720)
+++ trunk/refman-6.0/functions-core.xml 2010-11-12 19:25:37 UTC (rev 23721)
Changed blocks: 1, Lines Added: 218, Lines Deleted: 0; 8047 bytes
@@ -2018,6 +2018,224 @@
</section>
+ <section id="assignment-operators">
+
+ <title>Assignment Operators</title>
+
+ <indexterm>
+ <primary>assignment operators</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>operators</primary>
+ <secondary>assignment</secondary>
+ </indexterm>
+
+ <para condition="dynamic:opfuncs:fullsummary" role="5.1::assignment">
+ <citetitle>Assignment Operators</citetitle>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <remark role="help-topic" condition="assign-value"/>
+
+ <remark role="help-syntax-begin"/>
+
+ <para id="operator_assign-value">
+ <indexterm>
+ <primary>:= (assignment operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>assignment operator</primary>
+ <secondary>:=</secondary>
+ </indexterm>
+
+ <literal role="op" condition="assign-value">:=</literal>
+ </para>
+
+ <remark role="help-syntax-end"/>
+
+ <remark role="help-description-begin"/>
+
+ <para>
+ Assignment operator. Causes the user variable on the left
+ hand side of the operator to take on the value to its right.
+ The value on the right hand side may be a literal value,
+ another variable storing a value, or any legal expression
+ that yields a scalar value, including the result of a query
+ (provided that this value is a scalar value). You can
+ perform multiple assignments in the same
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement. You can perform multiple assignments in the same
+ statement-
+ </para>
+
+ <para>
+ Unlike
+ <literal role="op" condition="assign-equal">=</literal>, the
+ <literal role="op" condition="assign-value">:=</literal>
+ operator is never interpreted as a comparison operator. This
+ means you can use
+ <literal role="op" condition="assign-value">:=</literal> in
+ any valid SQL statement (not just in
+ <literal role="stmt" condition="set-option">SET</literal>
+ statements) to assign a value to a variable.
+ </para>
+
+ <remark role="help-description-end"/>
+
+ <remark role="help-example"/>
+
+<programlisting>
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> NULL, NULL
+mysql> <userinput>SELECT @var1 := 1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2 := @var1;</userinput>
+ -> 1, 1
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, 1
+
+mysql> <userinput>SELECT @var1:=COUNT(*) FROM t1;</userinput>
+ -> 4
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 4
+</programlisting>
+
+ <para>
+ You can make value assignments using
+ <literal role="op" condition="assign-value">:=</literal> in
+ other statements besides
+ <literal role="stmt">SELECT</literal>, such as
+ <literal role="stmt">UPDATE</literal>, as shown here:
+ </para>
+
+<programlisting>
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 4
+mysql> <userinput>SELECT * FROM t1;</userinput>
+ -> 1, 3, 5, 7
+
+mysql> <userinput>UPDATE t1 SET c1 = 2 WHERE c1 = @var1:= 1;</userinput>
+Query OK, 1 row affected (0.00 sec)
+Rows matched: 1 Changed: 1 Warnings: 0
+
+mysql> <userinput>SELECT @var1;</userinput>
+ -> 1
+mysql> <userinput>SELECT * FROM t1;</userinput>
+ -> 2, 3, 5, 7
+</programlisting>
+
+ <para>
+ While it is also possible both to set and to read the value
+ of the same variable in a single SQL statement using the
+ <literal role="op" condition="assign-value">:=</literal>
+ operator, this is not recommended.
+ <xref linkend="user-variables"/>, explains why you should
+ avoid doing this.
+ </para>
+ </listitem>
+
+ <listitem>
+ <remark role="help-topic" condition="assign-equal"/>
+
+ <remark role="help-syntax-begin"/>
+
+ <para id="operator_assign-equal">
+ <indexterm>
+ <primary>= (assignment operator)</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>assignment operator</primary>
+ <secondary>=</secondary>
+ </indexterm>
+
+ <indexterm>
+ <primary>SET statement</primary>
+ <secondary>assignment operator</secondary>
+ </indexterm>
+
+ <literal role="op" condition="assign-value">:=</literal>
+ </para>
+
+ <remark role="help-syntax-end"/>
+
+ <remark role="help-description-begin"/>
+
+ <para>
+ This operator is used to perform value assignments in two
+ cases, described in the next two paragraphs.
+ </para>
+
+ <para>
+ Within a
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement, <literal>=</literal> is treated as an assignment
+ operator that causes the user variable on the left hand side
+ of the operator to take on the value to its right. (In other
+ words, when used in a
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement, <literal>=</literal> is treated identically to
+ <literal role="op" condition="assign-value">:=</literal>.)
+ The value on the right hand side may be a literal value,
+ another variable storing a value, or any legal expression
+ that yields a scalar value, including the result of a query
+ (provided that this value is a scalar value). You can
+ perform multiple assignments in the same
+ <literal role="stmt" condition="set-option">SET</literal>
+ statement.
+ </para>
+
+ <para>
+ In the <literal>SET</literal> clause of an
+ <literal role="stmt">UPDATE</literal> statement,
+ <literal>=</literal> also acts as an assignment operator; in
+ this case, however, it causes the column named on the left
+ hand side of the operator to assume the value given to the
+ right, provided any <literal>WHERE</literal> conditions that
+ are part of the <literal role="stmt">UPDATE</literal> are
+ met. You can make multiple assignments in the same
+ <literal>SET</literal> clause of an
+ <literal role="stmt">UPDATE</literal> statement.
+ </para>
+
+ <para>
+ In any other context, <literal>=</literal> is treated as a
+ <link linkend="operator_equal">comparison operator</link>.
+ </para>
+
+ <remark role="help-description-end"/>
+
+ <remark role="help-example"/>
+
+<programlisting>
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> NULL, NULL
+mysql> <userinput>SELECT @var1 := 1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, NULL
+mysql> <userinput>SELECT @var1, @var2 := @var1;</userinput>
+ -> 1, 1
+mysql> <userinput>SELECT @var1, @var2;</userinput>
+ -> 1, 1
+</programlisting>
+
+ <para>
+ For more information, see <xref linkend="set-option"/>,
+ <xref linkend="update"/>, and <xref linkend="subqueries"/>.
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ </section>
+
</section>
<section id="control-flow-functions">
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r23721 - in trunk: dynamic-docs/opsfunctions refman-4.1 refman-5.0 refman-5.1 refman-5.5 refman-5.6 refman-6.0 | jon.stephens | 12 Nov |