对2列实施MySQL IN,以仅显示选定的记录
让我们首先创建一个表-
mysql> create table DemoTable810(First int,
Second int
);
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable810 values(20,40);mysql> insert into DemoTable810 values(70,90);
mysql> insert into DemoTable810 values(120,150);
mysql> insert into DemoTable810 values(78,128);
使用select语句显示表中的所有记录-
mysql> select *from DemoTable810 ;
这将产生以下输出-
+-------+--------+| First | Second |
+-------+--------+
| 20 | 40 |
| 70 | 90 |
| 120 | 150 |
| 78 | 128 |
+-------+--------+
4 rows in set (0.00 sec)
以下是为2列实现MySQL IN的查询-
mysql> select *from DemoTable810 where (First,Second) IN((120,150),(20,40));
这将产生以下输出-
+-------+--------+| First | Second |
+-------+--------+
| 20 | 40 |
| 120 | 150 |
+-------+--------+
2 rows in set (0.00 sec)
以上是 对2列实施MySQL IN,以仅显示选定的记录 的全部内容, 来源链接: utcz.com/z/331060.html