搜索查询中 MySQL 数据库字段类型?
以下是语法 −
select *from yourTableName where REGEXP_INSTR(yourColumnName,yourSearchValue);
为理解以上语法,让我们先创建一个表 −
mysql> create table demo64 −> ( −> id int not null auto_increment primary key, −> name varchar(40) −> ); Query OK, 0 rows affected (3.06 sec)
使用插入命令向表中插入一些记录 −
mysql> insert into demo64(name) values('John Smith');
Query OK, 1 row affected (0.21 sec)
mysql> insert into demo64(name) values('John Doe');
Query OK, 1 row affected (0.15 sec)
mysql> insert into demo64(name) values('Chris Brown');
Query OK, 1 row affected (0.08 sec)
mysql> insert into demo64(name) values('David Miller');
Query OK, 1 row affected (0.20 sec)
mysql> insert into demo64(name) values('Carol Taylor');
Query OK, 1 row affected (0.10 sec)使用 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)
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 程序设计
C++
C#
MongoDB
MySQL
Javascript
PHP