在某些带下划线的列值中使用 MySQL IN()
我们首先创建一个表 −
mysql> create table DemoTable1363 -> ( -> StudentId varchar(20) -> ); Query OK, 0 rows affected (0.57 sec)
使用 insert 命令在表中插入一些记录 −
mysql> insert into DemoTable1363 values('901');
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable1363 values('702');
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable1363 values('901_John_Doe');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable1363 values('1001_Carol_Taylor');
Query OK, 1 row affected (0.26 sec)使用 select 语句显示表中的所有记录 −
mysql> select * from DemoTable1363;
这将产生以下输出 −
+-------------------+ | StudentId | +-------------------+ | 901 | | 702 | | 901_John_Doe | | 1001_Carol_Taylor | +-------------------+ 4 rows in set (0.00 sec)
以下是实现 IN() 的 MySQL 查询 −
mysql> select * from DemoTable1363 where StudentId IN('702','1001');这将产生以下输出 −
+-----------+ | StudentId | +-----------+ | 702 | +-----------+ 1 row in set (0.00 sec)
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP