对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列实现MySQLIN的查询-
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)
热门推荐
10 写给男生简短的祝福语
11 成长仪式的简短祝福语
12 安徽疫情祝福语简短英语
13 姐妹分手了祝福语简短
14 早日回国祝福语简短英语
15 年前幸福祝福语大全简短
16 哥哥生日礼包祝福语简短
17 外婆祝福语短句唯美简短
18 新年的鸡汤祝福语简短