title: Find overlapping date ranges in PostgreSQL
body: <p>Is this correct?</p>
  
  <pre><code>SELECT * 
  FROM   contract 
  JOIN   team USING (name_team) 
  JOIN   player USING(name_player) 
  WHERE  name_team = ? 
  AND    DATE_PART('YEAR',date_join)&gt;= ? 
  AND    DATE_PART('YEAR',date_leave)&lt;= ?
  </code></pre>
  
  <p>My table <code>contract</code> has the player name, team name and the dates when he joined and left the club.<br>
  I want to make a function listing all players that were on the team in specific years.<br>
  The above query doesn't seem to be working ...</p>