title: MYSQL - Joins and what happened next query?
body: <p>I've set up a database to record the performance of a group of people picking sports events.
  So every day around 40 people choose an team or person or horse or whatever they think will win that day.</p>
  
  <p>The tables I have are Tipsters, Selections &amp; Choices. </p>
  
  <p>Tipsters is a list of all those involved.</p>
  
  <p>Selections is a list of all the choices made for each day. More than one tipster can choose the same selection.</p>
  
  <p>Choices is the 'choice' of the tipster  - also shows running totals of current win seq, current lose seq and running total to 1 pt stakes.</p>
  
  <p>My SQL isn't great but I've got enough to do the basics, join the tables etc.</p>
  
  <p>BUT ... I need to be able to do some 'what happened next' type of queries e.g I need to select those people who had a winning streak of 2 (or whatever) and find out what happened next. So if tipster #1 had selected a winning choice on 28th and 29th October, I need to have a query to be able to show what happened after that. I can do it programmatically (join the tables, select those with the relevant sequence, then take that result and select all later selections etc.) but could do with some SQL. Thanks in advance ... sample data below:</p>
  
  <pre><code>    Tipsters
  
   tid    tname
   1      RCFO
   2      DMN
   3      RPNK
   4      WPKY
   5      SSBG
   6      MEGJ
   7      SSCEKK
  
  Selections
  
   sid        sdate   sname
   1      2016-09-28  MT-name1
   2      2016-09-28  CCC
   3      2016-09-28  BDF
   4      2016-09-28  MA
   5      2016-09-28  EV
   6      2016-09-28  AQQ
   7      2016-09-28  ERAA
   8      2016-09-28  SL
   9      2016-09-28  SHWM
   10     2016-09-28  OM
   748    2016-10-21  MD
  
  Choices
  
   tid    sid     sqw sqf     running
   1      1       0   3       -7.56
   2      2       0   3       -13.57
   3      3       0   4       -18.96
   4      4       0   3       36.75
   5      5       0   4       -0.33
   6      6       3   0       8.41
   7      7       0   4       5.23
   8      7       0   16      -27.49
   1      88      0   1       -5.56
   2      89      0   5       -15.57
   7      97      0   7       2.23
   3      97      0   1       -19.86
  
  SELECT selections.seldate, selections.selection, selections.rtime, selections.result, selections.sp
  FROM choices 
  JOIN selections ON selections.id = choices.selid AND sqw = 2 
  JOIN tipsters ON tipsters.id = choices.tipid
  ORDER BY selections.seldate asc, rtime asc, selection ASC
  </code></pre>