title: How to write a query to get route id based on multiple parameters?
body: <p>I designed this simple model and I am with some difficulties to write the desirable query.</p>
  <p>To start with, here's the markdown of the 3 tables that I have:</p>
  <p><strong>SELECT * FROM Routes;</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Id</th>
  <th>Content</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>Route 1</td>
  </tr>
  <tr>
  <td>2</td>
  <td>Route 2</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><strong>SELECT * FROM PointsOfInterest;</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Id</th>
  <th>Name</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>Oceanário</td>
  </tr>
  <tr>
  <td>2</td>
  <td>Mosteiro dos Jerónimos</td>
  </tr>
  <tr>
  <td>3</td>
  <td>Torre de Belém</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><strong>SELECT * FROM Routes_PointsOfInterest;</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>RouteId</th>
  <th>PointOfInterestId</th>
  <th>Order_Position</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>1</td>
  <td>1</td>
  </tr>
  <tr>
  <td>1</td>
  <td>2</td>
  <td>2</td>
  </tr>
  <tr>
  <td>1</td>
  <td>3</td>
  <td>3</td>
  </tr>
  <tr>
  <td>2</td>
  <td>1</td>
  <td>3</td>
  </tr>
  <tr>
  <td>2</td>
  <td>2</td>
  <td>2</td>
  </tr>
  <tr>
  <td>2</td>
  <td>3</td>
  <td>1</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I need to find the RouteId for multiple points of interested in a known order. So, for example, I need to find the route corresponding to the points of interest 1, 2 and 3 in the order 1-&gt;2-&gt;3. So this one should return RouteId=1. However, for the same points of interest 1, 2 and 3, in the order (3-&gt;2-&gt;1) the RouteId should be 2.</p>
  <p>Basically this means that the route from PoI 1 to PoI 3 is different from the route from PoI 3 to PoI 1.</p>
  <p>I designed this tables, so maybe this isn't the best approach to design the tables. If it helps, I can alter all this schema.</p>
  <p>Here's the minimum amount of code to reproduce my problem:
  <a href="http://sqlfiddle.com/#!9/0cdee8/1" rel="nofollow noreferrer">http://sqlfiddle.com/#!9/0cdee8/1</a>
  or
  <a href="https://www.db-fiddle.com/f/v3GZPCHpmdyBRCFGCsr2im/0" rel="nofollow noreferrer">https://www.db-fiddle.com/f/v3GZPCHpmdyBRCFGCsr2im/0</a></p>
  <p>Thank you for your help!</p>