title: SQL Query loop through two arrays?
body: <p>I am using the below SQL Query in a PHP application to find matching id for each stop.</p>
  
  <pre><code>$sql = "SELECT trip_id FROM stop_times WHERE stop_id='5897' AND stop_id='1373'";
  </code></pre>
  
  <p>What I would like to do is to have it loop through my two arrays <code>$toStop</code> and <code>$fromStop</code> and find <code>trip_id</code>'s that matches then output the results.</p>
  
  <pre><code>$toStop = array("1373","1376","1372","7316","5697","2748","2749","1375","1377","7368","1374","2787","2788");
  $fromStop = array("5897","7311","7146","7129","0020","3705","0039","7128","3806","7152","7190","5941","5185","7189","0001","0038","0021","3394","0019","0031","7155","0030");
  </code></pre>
  
  <p>Something like this? But I don't think this would work.</p>
  
  <pre><code>    for ($i = 0; $i &lt; count($array1); ++$i) {
          for ($i = 0; $i &lt; count($array2); ++$i) {
              SELECT trip_id FROM stop_times WHERE stop_id=$array1[$i] AND stop_id=$array2[$i]
      }
  }
  </code></pre>
  
  <p>Sample of Database after query:</p>
  
  <pre><code>SELECT trip_id, stop_id
  FROM `stop_times`
  WHERE stop_id = '1538'
  
  L66220600132482     1538
  0051ML66220630143389    1538
  0051ML66220700154239    1538
  0051ML66220715159618    1538
  0051ML66220730165473    1538
  0051ML66220745170994    1538
  0051ML66220800176259    1538
  0051ML66220815181524    1538
  0051ML66220830185989    1538
  0070ML577519153855214   1538
  0070ML577520154046960   1538
  0070ML577521154237374   1538
  0072ML577707101039907   1538
  0072ML577707351095644   1538
  0072ML577708101171393   1538
  0072ML577708451246468   1538
  0072ML577715402171497   1538
  0072ML577716102237827   1538
  0072ML577716402305231   1538
  0072ML577717102370287   1538
  0072ML577717402429337   1538
  0074ML575808001813962   1538
  0074ML575808051829094   1538
  0074ML575808051833737   1538
  0074ML575808351938317   1538
  0074ML575808351942909   1538
  0074ML575809052042897   1538
  0074ML575809052043418   1538
  0074ML575809152083611   1538
  0074ML575809352147477   1538
  </code></pre>
  
  <p>|</p>