title: SQL get players who played for 3 consecutive years on team
body: <p>I'm new to using MySQL and am stuck on a query I have to write. Given a database of baseball players in the MLB, and all their statistics, I need to write a query that will show which players played for at least 3 consecutive years on the Boston Red Sox baseball team. Here's what I have so far:</p>
  
  <pre><code>SELECT player.nameFirst, player.nameLast
  FROM player
  WHERE (...something something...) &gt;= 3
  AND player.teamID = "Boston Red Sox"
  </code></pre>
  
  <p>As well as the player table, there is another table called appears, which contains the playerID, and then the year they played for a team. The appears table also has other information such as their stats for that season. For example if one player played for the red sox 4 years, we would see four rows in the appears table, each row with an integer indicating what year they played on that team. </p>
  
  <p>I know that after where the query gets complicated, I'm not sure how I would first off, count the number of years the player has been on the team, let alone how to know if those years were consecutive or not. Thanks for the help!</p>