ID|回合
1 | 1
2 | 2
3 | 2
4 | 1
1 | 3
4 | 4
SQL 新手,如果我弄错了词典,请原谅我。我试图弄清楚如何指定一个 where 子句,以便我可以隔离 ID 与第 1 轮中出现的 ID 匹配的所有行(无论第 1 轮)。首选输出是这样的:
ID|回合
1 | 1
4 | 1
1 | 3
4 | 4
ID 1 和 4 出现在第 1 轮中,所以我想要所有具有 ID 1 或 4 的行(并排除没有出现在第 1 轮中的 ID,即 ID 2 和 3)。
任何帮助将不胜感激,因为我似乎无法制定一个搜索结果来解决这个问题。在 MySQL 中工作(如果这有所作为)。
最佳答案
这应该有效:
select * from table where id in(select id from table where round = 1
关于mysql - Where 语句 : isolating matching values in one column based on the attributes of another,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48170341/