我是休眠的新手。这是一张User
桌子
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id | int(11) | NO | PRI | NULL | |
| name | varchar(16) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
| sex | char(1) | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
这是我的样本数据
+----+-------+------+------+
| id | name | age | sex |
+----+-------+------+------+
| 1 | Amit | 20 | M |
| 2 | Sumit | 21 | M |
| 3 | Mohan | 22 | M |
| 4 | Ram | 26 | M |
| 5 | John | 22 | M |
| 6 | Sita | 19 | F |
+----+-------+------+------+
这些是我的疑问:
select id from User where name="Amit" and age=20;
select id from User where name="Ram" and age=26;
select id from User where name="Mohan" and age=22;
select id from User where name="Sita" and age=19;
我可以通过运行 4 个查询在休眠状态下做到这一点。有什么方法可以让我在一个查询中做到这一点?请告诉同样可以在mysql中完成。请帮忙。任何线索、链接或参考都将是可观的。谢谢你。