我有一张表,其结构是:
+----+-------+----------+
| ID | Class | Names |
+----+-------+----------+
| 1 | Paper | Ed |
+----+-------+----------+
| 2 | Glass | Pete |
+----+-------+----------+
| 3 | Glass | Ed |
+----+-------+----------+
| 4 | Rock | Fred |
+----+-------+----------+
我想找到有一类纸和玻璃的名字。所以在这个小表中它会返回:
+----+-------+----------+
| ID | Class | Names |
+----+-------+----------+
| 1 | Paper | Ed |
+----+-------+----------+
| 3 | Glass | Ed |
+----+-------+----------+
但是,名称不能是查询的一部分。必须找到 class = paper 和 class = glass 的名称。所以我只想要有纸和玻璃的名字。
简化的 SQL 将是:
SELECT Names
FROM table WHERE Class
= Paper AND Class
= Glass
显然,这不起作用,因为一行只有一个类值。
TIA