我有一个表格,大致如下:
Runners Leagues Matches Line InDict
Team 1 LeagueA Match 1 Line 1 'Yes'
Team 2 LeagueA Match 1 Line 1 'Yes'
Team 3 LeagueA Match 1 Line 1 'No'
Team 1 LeagueA Match 4 Line 1 'Yes'
Team 2 LeagueA Match 4 Line 1 'Yes'
Team 1 LeagueA Match 1 Line 2 'Yes'
Team 2 LeagueA Match 1 Line 2 'Yes'
Team 3 LeagueA Match 1 Line 2 'Yes'
Team 1 LeagueB Match 5 Line 8 'No'
Team 2 LeagueB Match 5 Line 8 'Yes'
我想要做的是选择联赛/比赛/线列相同的所有行,如果这些行之一在 InDict 列中包含值“否”。因此,在上面的示例中,查询将返回:
Team 1 LeagueA Match 1 Line 1 'Yes'
Team 2 LeagueA Match 1 Line 1 'Yes'
Team 3 LeagueA Match 1 Line 1 'No'
Team 1 LeagueB Match 5 Line 8 'No'
Team 2 LeagueB Match 5 Line 8 'Yes'
我是 mysql 新手,因此我正在努力寻找用于此目的的正确查询。
非常感谢任何帮助!
最佳答案
MySQL 允许您在 in
运算符中使用多列子查询:
select *
from TableName
where (Leagues,Matches,Line) in (
select Leagues,Matches,Line
from TableName
where InDict='''No'''
)
关于mysql - 如果一列包含特定值,则选择具有相同 ID 的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28377141/