먼저 테이블을 생성하겠습니다 -
mysql> create table DemoTable -> ( -> Title varchar(255) -> ); Query OK, 0 rows affected (1.82 sec)
삽입 명령을 사용하여 테이블에 일부 레코드 삽입 -
mysql> insert into DemoTable values('John is a good player'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values('No,John Doe is not a good player'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Yes,Adam Smith is play cricket match'); Query OK, 1 row affected (0.28 sec) mysql> alter table DemoTable add fulltext(Title); Query OK, 0 rows affected, 1 warning (10.60 sec) Records: 0 Duplicates: 0 Warnings: 1
select 문을 사용하여 테이블의 모든 레코드 표시 -
mysql> select *from DemoTable;
이것은 다음과 같은 출력을 생성합니다 -
+--------------------------------------+ | Title | +--------------------------------------+ | John is a good player | | No,John Doe is not a good player | | Yes,Adam Smith is play cricket match | +--------------------------------------+ 3 rows in set (0.00 sec)
다음은 MySQL에서 특정 단어를 검색하는 쿼리입니다 -
mysql> select *from DemoTable -> where Title REGEXP '^.*John.*$';
이것은 다음과 같은 출력을 생성합니다 -
+----------------------------------+ | Title | +----------------------------------+ | John is a good player | | No,John Doe is not a good player | +----------------------------------+ 2 rows in set (0.11 sec)