| 1 |
drop table if exists t1; |
| 2 |
CREATE TABLE t1 ( |
| 3 |
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, |
| 4 |
a VARCHAR(200), |
| 5 |
b TEXT |
| 6 |
) ENGINE = InnoDB STATS_PERSISTENT=0; |
| 7 |
INSERT INTO t1 (a,b) VALUES |
| 8 |
('MySQL Tutorial','DBMS stands for DataBase ...') , |
| 9 |
('How To Use MySQL Well','After you went through a ...'), |
| 10 |
('Optimizing MySQL','In this tutorial we will show ...'); |
| 11 |
ALTER TABLE t1 ADD FULLTEXT INDEX idx_1 (a); |
| 12 |
Warnings: |
| 13 |
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID |
| 14 |
ALTER TABLE t1 ADD FULLTEXT INDEX idx_2 (b); |
| 15 |
SHOW CREATE TABLE t1; |
| 16 |
Table Create Table |
| 17 |
t1 CREATE TABLE `t1` ( |
| 18 |
`id` int unsigned NOT NULL AUTO_INCREMENT, |
| 19 |
`a` varchar(200) DEFAULT NULL, |
| 20 |
`b` text, |
| 21 |
PRIMARY KEY (`id`), |
| 22 |
FULLTEXT KEY `idx_1` (`a`), |
| 23 |
FULLTEXT KEY `idx_2` (`b`) |
| 24 |
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci STATS_PERSISTENT=0 |
| 25 |
START TRANSACTION; |
| 26 |
INSERT INTO t1 (a,b) VALUES |
| 27 |
('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), |
| 28 |
('MySQL vs. YourSQL','In the following database comparison ...'), |
| 29 |
('MySQL Security','When configured properly, MySQL ...'); |
| 30 |
ROLLBACK; |
| 31 |
SELECT * FROM t1 WHERE MATCH (a) |
| 32 |
AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); |
| 33 |
id a b |
| 34 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 35 |
select * from t1 where MATCH(a) AGAINST("+mysql +Tutorial" IN BOOLEAN MODE); |
| 36 |
id a b |
| 37 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 38 |
select * from t1 where MATCH(b) AGAINST("+Tutorial" IN BOOLEAN MODE); |
| 39 |
id a b |
| 40 |
3 Optimizing MySQL In this tutorial we will show ... |
| 41 |
select * from t1 where MATCH(b) AGAINST("+stands +(DataBase)" IN BOOLEAN MODE); |
| 42 |
id a b |
| 43 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 44 |
select * from t1 where MATCH(b) AGAINST("+DataBase -(comparison)" IN BOOLEAN MODE); |
| 45 |
id a b |
| 46 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 47 |
select *, MATCH(a) AGAINST("Optimizing MySQL" IN BOOLEAN MODE) as x from t1; |
| 48 |
id a b x |
| 49 |
1 MySQL Tutorial DBMS stands for DataBase ... 0.0906190574169159 |
| 50 |
2 How To Use MySQL Well After you went through a ... 0.0906190574169159 |
| 51 |
3 Optimizing MySQL In this tutorial we will show ... 0.6961383819580078 |
| 52 |
select *, MATCH(b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; |
| 53 |
id a b x |
| 54 |
1 MySQL Tutorial DBMS stands for DataBase ... 0 |
| 55 |
2 How To Use MySQL Well After you went through a ... 0 |
| 56 |
3 Optimizing MySQL In this tutorial we will show ... 0 |
| 57 |
select * from t1 where MATCH a AGAINST ("+Optimiz* +Optimiz*" IN BOOLEAN MODE); |
| 58 |
id a b |
| 59 |
3 Optimizing MySQL In this tutorial we will show ... |
| 60 |
select * from t1 where MATCH b AGAINST ('"DBMS stands"' IN BOOLEAN MODE); |
| 61 |
id a b |
| 62 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 63 |
select * from t1 where MATCH b AGAINST ('"DBMS STANDS"' IN BOOLEAN MODE); |
| 64 |
id a b |
| 65 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 66 |
select * from t1 where MATCH(b) AGAINST ("DataBase" WITH QUERY EXPANSION); |
| 67 |
id a b |
| 68 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 69 |
select * from t1 where MATCH(a) AGAINST ("Security" WITH QUERY EXPANSION); |
| 70 |
id a b |
| 71 |
ALTER TABLE t1 DROP INDEX idx_1; |
| 72 |
ALTER TABLE t1 DROP INDEX idx_2; |
| 73 |
ALTER TABLE t1 ADD FULLTEXT INDEX idx_1 (a); |
| 74 |
ALTER TABLE t1 ADD FULLTEXT INDEX idx_2 (b); |
| 75 |
SELECT * FROM t1 WHERE MATCH (a) |
| 76 |
AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); |
| 77 |
id a b |
| 78 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 79 |
select * from t1 where MATCH(a) AGAINST("+mysql +Tutorial" IN BOOLEAN MODE); |
| 80 |
id a b |
| 81 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 82 |
select * from t1 where MATCH(b) AGAINST("+Tutorial" IN BOOLEAN MODE); |
| 83 |
id a b |
| 84 |
3 Optimizing MySQL In this tutorial we will show ... |
| 85 |
select * from t1 where MATCH(b) AGAINST("+stands +(DataBase)" IN BOOLEAN MODE); |
| 86 |
id a b |
| 87 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 88 |
select * from t1 where MATCH(b) AGAINST("+DataBase -(comparison)" IN BOOLEAN MODE); |
| 89 |
id a b |
| 90 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 91 |
select *, MATCH(a) AGAINST("Optimizing MySQL" IN BOOLEAN MODE) as x from t1; |
| 92 |
id a b x |
| 93 |
1 MySQL Tutorial DBMS stands for DataBase ... 0.0906190574169159 |
| 94 |
2 How To Use MySQL Well After you went through a ... 0.0906190574169159 |
| 95 |
3 Optimizing MySQL In this tutorial we will show ... 0.6961383819580078 |
| 96 |
select *, MATCH(b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; |
| 97 |
id a b x |
| 98 |
1 MySQL Tutorial DBMS stands for DataBase ... 0 |
| 99 |
2 How To Use MySQL Well After you went through a ... 0 |
| 100 |
3 Optimizing MySQL In this tutorial we will show ... 0 |
| 101 |
select * from t1 where MATCH a AGAINST ("+Optimiz* +Optimiz*" IN BOOLEAN MODE); |
| 102 |
id a b |
| 103 |
3 Optimizing MySQL In this tutorial we will show ... |
| 104 |
select * from t1 where MATCH b AGAINST ('"DBMS stands"' IN BOOLEAN MODE); |
| 105 |
id a b |
| 106 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 107 |
select * from t1 where MATCH b AGAINST ('"DBMS STANDS"' IN BOOLEAN MODE); |
| 108 |
id a b |
| 109 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 110 |
select * from t1 where MATCH(b) AGAINST ("DataBase" WITH QUERY EXPANSION); |
| 111 |
id a b |
| 112 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 113 |
select * from t1 where MATCH(a) AGAINST ("Security" WITH QUERY EXPANSION); |
| 114 |
id a b |
| 115 |
INSERT INTO t1 (a,b) VALUES ('test query expansion','for database ...'); |
| 116 |
INSERT INTO t1 (a,b) VALUES |
| 117 |
('test proximity search, test, proximity and phrase', |
| 118 |
'search, with proximity innodb'); |
| 119 |
INSERT INTO t1 (a,b) VALUES |
| 120 |
('test proximity fts search, test, proximity and phrase', |
| 121 |
'search, with proximity innodb'); |
| 122 |
INSERT INTO t1 (a,b) VALUES |
| 123 |
('test more of proximity for fts search, test, more proximity and phrase', |
| 124 |
'search, with proximity innodb'); |
| 125 |
SELECT * FROM t1 |
| 126 |
WHERE MATCH (a) |
| 127 |
AGAINST ('"proximity search"@3' IN BOOLEAN MODE); |
| 128 |
id a b |
| 129 |
8 test proximity search, test, proximity and phrase search, with proximity innodb |
| 130 |
9 test proximity fts search, test, proximity and phrase search, with proximity innodb |
| 131 |
SELECT * FROM t1 |
| 132 |
WHERE MATCH (a) |
| 133 |
AGAINST ('"proximity search"@2' IN BOOLEAN MODE); |
| 134 |
id a b |
| 135 |
8 test proximity search, test, proximity and phrase search, with proximity innodb |
| 136 |
SELECT * FROM t1 |
| 137 |
WHERE MATCH (b) |
| 138 |
AGAINST ('"proximity innodb"@4' IN BOOLEAN MODE); |
| 139 |
id a b |
| 140 |
8 test proximity search, test, proximity and phrase search, with proximity innodb |
| 141 |
9 test proximity fts search, test, proximity and phrase search, with proximity innodb |
| 142 |
10 test more of proximity for fts search, test, more proximity and phrase search, with proximity innodb |
| 143 |
SELECT * FROM t1 |
| 144 |
WHERE MATCH (a) |
| 145 |
AGAINST ('"test proximity"@3' IN BOOLEAN MODE); |
| 146 |
id a b |
| 147 |
8 test proximity search, test, proximity and phrase search, with proximity innodb |
| 148 |
9 test proximity fts search, test, proximity and phrase search, with proximity innodb |
| 149 |
10 test more of proximity for fts search, test, more proximity and phrase search, with proximity innodb |
| 150 |
SELECT * FROM t1 |
| 151 |
WHERE MATCH (a) |
| 152 |
AGAINST ('"more test proximity"@3' IN BOOLEAN MODE); |
| 153 |
id a b |
| 154 |
10 test more of proximity for fts search, test, more proximity and phrase search, with proximity innodb |
| 155 |
SELECT * FROM t1 |
| 156 |
WHERE MATCH (a) |
| 157 |
AGAINST ('"more test proximity"@2' IN BOOLEAN MODE); |
| 158 |
id a b |
| 159 |
SELECT * FROM t1 |
| 160 |
WHERE MATCH (a) |
| 161 |
AGAINST ('"more fts proximity"@02' IN BOOLEAN MODE); |
| 162 |
id a b |
| 163 |
SELECT * FROM t1 WHERE CONCAT(t1.a,t1.b) IN ( |
| 164 |
SELECT CONCAT(a,b) FROM t1 AS t2 WHERE |
| 165 |
MATCH (t2.a) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) |
| 166 |
) OR t1.id = 3 ; |
| 167 |
id a b |
| 168 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 169 |
3 Optimizing MySQL In this tutorial we will show ... |
| 170 |
SELECT * FROM t1 WHERE CONCAT(t1.a,t1.b) IN ( |
| 171 |
SELECT CONCAT(a,b) FROM t1 AS t2 |
| 172 |
WHERE MATCH (t2.a) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) |
| 173 |
AND t2.id != 3) ; |
| 174 |
id a b |
| 175 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 176 |
SELECT * FROM t1 WHERE id IN (SELECT MIN(id) FROM t1 WHERE |
| 177 |
MATCH (b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)) OR id = 3 ; |
| 178 |
id a b |
| 179 |
3 Optimizing MySQL In this tutorial we will show ... |
| 180 |
SELECT * FROM t1 WHERE id NOT IN (SELECT MIN(id) FROM t1 |
| 181 |
WHERE MATCH (b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)) ; |
| 182 |
id a b |
| 183 |
1 MySQL Tutorial DBMS stands for DataBase ... |
| 184 |
2 How To Use MySQL Well After you went through a ... |
| 185 |
7 test query expansion for database ... |
| 186 |
8 test proximity search, test, proximity and phrase search, with proximity innodb |
| 187 |
9 test proximity fts search, test, proximity and phrase search, with proximity innodb |
| 188 |
10 test more of proximity for fts search, test, more proximity and phrase search, with proximity innodb |
| 189 |
SELECT * FROM t1 WHERE EXISTS (SELECT t2.id FROM t1 AS t2 WHERE |
| 190 |
MATCH (t2.b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) |
| 191 |
AND t1.id = t2.id) ; |
| 192 |
id a b |
| 193 |
3 Optimizing MySQL In this tutorial we will show ... |
| 194 |
SELECT * FROM t1 WHERE NOT EXISTS (SELECT t2.id FROM t1 AS t2 WHERE |
| 195 |
MATCH (t2.a) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) |
| 196 |
AND t1.id = t2.id) ; |
| 197 |
id a b |
| 198 |
2 How To Use MySQL Well After you went through a ... |
| 199 |
3 Optimizing MySQL In this tutorial we will show ... |
| 200 |
7 test query expansion for database ... |
| 201 |
8 test proximity search, test, proximity and phrase search, with proximity innodb |
| 202 |
9 test proximity fts search, test, proximity and phrase search, with proximity innodb |
| 203 |
10 test more of proximity for fts search, test, more proximity and phrase search, with proximity innodb |
| 204 |
SELECT * FROM t1 WHERE t1.id = (SELECT MAX(t2.id) FROM t1 AS t2 WHERE |
| 205 |
MATCH(t2.a) AGAINST ('"proximity search"@3' IN BOOLEAN MODE)); |
| 206 |
id a b |
| 207 |
9 test proximity fts search, test, proximity and phrase search, with proximity innodb |
| 208 |
SELECT * FROM t1 WHERE t1.id > (SELECT MIN(t2.id) FROM t1 AS t2 WHERE |
| 209 |
MATCH(t2.b) AGAINST ('"proximity innodb"@3' IN BOOLEAN MODE)); |
| 210 |
id a b |
| 211 |
9 test proximity fts search, test, proximity and phrase search, with proximity innodb |
| 212 |
10 test more of proximity for fts search, test, more proximity and phrase search, with proximity innodb |
| 213 |
DROP TABLE t1; |