56.筆記 mysql學習——布林模式全文搜尋
布林模式有以下特點:
l 即使找到的單詞會出現在一半以上的行裡,仍然會把它們搜搜出來
l 查詢結果不再按相關程式排序
l 搜尋可以要求短語裡的所有單詞都必須是按某種特定的順序出現
l 可以對未包括在fulltex索引裡的那些列,進行布林模式全文搜尋
如果要匹配乙個短語,那麼需要把它用雙引號引起來。只有在行包含的那些單詞及其順序與短語裡列出的內容一致時,才會被認為是匹配上了。
如下:mysql> select * from apothegm wherematch(attribution,phrase) against ( '"bell book and candle"' inboolean mode);
| attribution | phrase |
| miguel de cervantes | bell, book, andcandle |
1 row in set (0.00 sec)
mysql> select * from apothegm wherematch(attribution,phrase) against ( '"book bell and candle"' inboolean mode);
empty set (0.00 sec)
對於布林模式搜尋,還可以為搜尋字串裡的單詞加上些修飾符,例如加號,減號。
搜尋字串』bell –candle』只會與那些包含了『bell』但不包含candle的行
mysql> select * from apothegm wherematch(attribution,phrase) against ('bell');
| attribution | phrase |
| alexander graham bell | mr. watson, comehere. i want you! |
| miguel de cervantes | bell, book, and candle |
2 rows in set (0.00 sec)
mysql> select * from apothegm wherematch(attribution,phrase) against ('+bell -candle' in boolean mode);
| attribution | phrase |
| alexander graham bell | mr. watson, comehere. i want you! |
1 row in set (0.00 sec)
9 筆記 MySQL學習 處理日期
9.筆記 mysql學習 處理日期 mysql支援多種型別的日期運算 l 按日期排序 l 搜尋特定日期或日期範圍 l 從日期值裡提取各組成部分 l 計算兩個日期之間的時間差 l 通過將乙個日期加上或減去乙個時間間隔 處理日期 查詢某一天的記錄 mysql select from grade even...
20 筆記 MySQL學習 InnoDB儲存引擎
20.筆記 mysql學習 innodb儲存引擎 innodb儲存引擎是mysql的預設引擎。有幾項功能 n 其表在執行提交和回滾操作時是事務安全的。n 在系統崩潰後可以自動恢復 n 外來鍵和引用完整性支援,包括級聯刪除和更新 n 基於行級別的鎖定和多版本化 n 從mysql 5.6開始,innod...
44 筆記 MySQL學習 相關子查詢
44.筆記 mysql學習 相關子查詢 子查詢要不要相關都可以。不相關的子查詢不會引發外層查詢裡的值,因為可以作為一條單獨的查詢命令來執行。相關子查詢應用了外層查詢裡的值,也就依賴於外層查詢。相關子查詢通常用在exists和not exists子查詢裡,主要用於在某個表裡查詢在另乙個表裡有匹配行或沒...