MySQL数据库字段类型用于搜索查询?
以下是语法-
select *from yourTableName where REGEXP_INSTR(yourColumnName,yourSearchValue);
要了解上述语法,让我们首先创建一个表-
mysql> create table demo64 −> ( −> id int not null auto_increment primary key, −> name varchar(40) −> );
借助insert命令将一些记录插入表中-
mysql> insert into demo64(name) values('John Smith');
mysql> insert into demo64(name) values('John Doe');
mysql> insert into demo64(name) values('Chris Brown');
mysql> insert into demo64(name) values('David Miller');
mysql> insert into demo64(name) values('Carol Taylor');使用select语句显示表中的记录-
mysql> select *from demo64;
这将产生以下输出-
+----+--------------+ | id | name | +----+--------------+ | 1 | John Smith | | 2 | John Doe | | 3 | Chris Brown | | 4 | David Miller | | 5 | Carol Taylor | +----+--------------+ 5 rows in set (0.00 sec)
以下是字段类型搜索查询的查询-
mysql> select *from demo64 where REGEXP_INSTR(name,'John');
这将产生以下输出-
+----+------------+ | id | name | +----+------------+ | 1 | John Smith | | 2 | John Doe | +----+------------+ 2 rows in set (0.00 sec)
热门推荐
10 长辈生日祝福语简短女性
11 职场离职文案祝福语简短
12 回国了祝福语简短英语
13 文学短句祝福语大全简短
14 婚礼祝福语简短精辟的
15 圣诞祝福语简短小学
16 婚庆花篮祝福语简短大气
17 女神节日简短祝福语大全
18 关于开车的祝福语简短