将UNION换位UNION ALL可以可以包含不同SELECT子句选中的重复的列
17.2 UNION规则
1)UNION必须由两条或两条以上的SELECT语句组成,语句之间用关键字UNION分隔。
2)UNION中的 每个查询必须包含相同的列、表达式或聚集函数
3)列数据类型可以不完全相同,但必须兼容
17.3对组合查询结果排序
ORDER BY必须出现在最后一条SELECT语句之后
18.全文本搜索
在进行全文本搜索之前,首先应将表中的一列或多列设为FULLTEXT。然后使用Match()和Against()执行全文搜索,其中Match()指定被搜索的列,Against()指定要使用的搜索表达式。
18.1进行全文本搜索
SELECT note_text FROM productnotes WHERE Match(note_text)Against('rabbit');
+-------------------------------------------------------------------------------
----------------------------------------+
| note_text
|
+-------------------------------------------------------------------------------
----------------------------------------+
| Customer complaint: rabbit has been ableto detect trap, food apparently less
effective now. |
| Quantity varies, sold by the sack load.
All guaranteed to be bright and orange, andsuitable for use as rabbit bait. |
+-------------------------------------------------------------------------------
----------------------------------------+
2 rows in set (0.05 sec)
上面输出的两行结果的输出顺序是进过排序后得到的,也就是包含词rabbit作为第3个词的等级比作为第20个词的行高。下面演示全文本搜索如何排序工作。
mysql> SELECT note_text,Match(note_text)Against('rabbit') AS rank FROM productn
otes;
+-------------------------------------------------------------------------------
-----------------------------------------------------------------------------+--
----------------+
| note_text
| r
ank |
+-------------------------------------------------------------------------------
-----------------------------------------------------------------------------+--
----------------+
| Customer complaint:
Sticks not individually wrapped, too easyto mistakenly detonate all at once.
Recommend individual wrapping. | 0 |
| Can shipped full, refills not available.
Need to order new can if refill needed.
| 0 |
| Safe is combination locked, combinationnot provided with safe.
This is rarely a problem as safes aretypically blown up or dropped by customers
. | 0 |
| Quantity varies, sold by the sack load.
All guaranteed to be bright and orange, andsuitable for use as rabbit bait.
| 1.59055435657501 |
| Included fuses are short and have beenknown to detonate too quickly for some
customers.
Longer fuses are available (item FU1) andshould be recommended. |
0 |
| Matches not included, recommend purchaseof matches or detonator (item DTNTR).
|
0 |
| Please note that no returns will beaccepted if safe opened using explosives.
|
0 |
| Multiple customer returns, anvils failingto drop fast enough or falling backw
ards on purchaser. Recommend that customerconsiders using heavier anvils. |
0 |
| Item is extremely heavy. Designed for dropping,not recommended for use with s
lings, ropes, pulleys, or tightropes. |
0 |
| Customer complaint: rabbit has been ableto detect trap, food apparently less
effective now. | 1
.64080536365509 |
| Shipped unassembled, requires commontools (including oversized hammer).
|
0 |
| Customer complaint:
Circular hole in safe floor can apparentlybe easily cut with handsaw.
| 0 |
| Customer complaint:
Not heavy enough to generate flying starsaround head of victim. If being purcha
sed for dropping, recommend ANV02 or ANV03instead. | 0 |
| Call from individual trapped in safeplummeting to the ground, suggests an esc
ape hatch b