我正在使用以下SELECT来获取所有2012年来自NFL游戏的游戏数据库
Select gameid, season, off, description, qtr, down, ydstogoal
FROM 2010_12pxp
WHERE DESCRIPTION LIKE "%up the middle%" OR DESCRIPTION REGEXP "(left|right) (tackle|guard|end)" OR DESCRIPTION REGEXP " rushe(d|s) for "
AND season = 2012
GROUP BY id
但是,它将返回数据库中所有正在运行的游戏,而不仅仅是2012年的游戏。示例:
gameid season off description qtr down ydstogoal
20100909_MIN@NO 2010 NO (13:36) R.Bush left end pushed ob at MIN 29 for 8 yards (M.Williams A.Allen). 1 2 37
20100909_MIN@NO 2010 MIN (12:56) A.Peterson right tackle to MIN 23 for 3 yards (R.Harper). 1 1 80
20100909_MIN@NO 2010 MIN (12:16) A.Peterson right tackle to MIN 28 for 5 yards (J.Vilma). 1 2 77
20100909_MIN@NO 2010 MIN (11:38) A.Peterson left guard to MIN 27 for -1 yards (S.Shanle J.Dunbar). 1 3 72
20100909_MIN@NO 2010 MIN (8:38) A.Peterson left tackle to MIN 41 for 2 yards (J.Vilma S.Shanle). 1 3 61
20100909_MIN@NO 2010 MIN (7:51) A.Peterson right end to NO 42 for 17 yards (R.Gay). PENALTY on MIN-V.Shiancoe Offensive Holding 10 yards enforced at MIN 41 - No Play. 1 2 59
如何按季(2012)和/或仅限团队过滤?
提前致谢。
答案 0 :(得分:0)
使用额外的括号
Select gameid, season, off, description, qtr, down, ydstogoal
FROM 2010_12pxp
WHERE
(
DESCRIPTION LIKE "%up the middle%"
OR DESCRIPTION REGEXP "(left|right) (tackle|guard|end)"
OR DESCRIPTION REGEXP " rushe(d|s) for "
)
AND season = 2012
GROUP BY id
如果不,那么您的查询将被解释为
WHERE DESCRIPTION LIKE "%up the middle%"
OR DESCRIPTION REGEXP "(left|right) (tackle|guard|end)"
OR
(
DESCRIPTION REGEXP " rushe(d|s) for "
AND season = 2012
)