MySQL :: MySQL 5.0 Reference Manual :: 12.2.8.3 UNION Syntax
The column names from the first
SELECTstatement are used as the
column names for the results returned. Selected columns listed
in corresponding positions of each
SELECTstatement should have the
same data type. (For example, the first column selected by the
first statement should have the same type as the first column
selected by the other statements.)
If the data types of corresponding
SELECTcolumns do not match, the
types and lengths of the columns in theUNION
result take into account the values retrieved by all of the
SELECTstatements. For example,
consider the following:
- You can mix
UNION ALLandUNIONin the same query. Mixed
DISTINCT
UNIONtypes are treated such that a
DISTINCTunion overrides any
ALLunion to its left. A
DISTINCTunion can be produced explicitly by
usingUNION DISTINCTor implicitly by using
UNIONwith no following
DISTINCTorALLkeyword.
Posted from Diigo. The rest of vincenthome group favorite links are here.
没有评论:
发表评论