title: Include a complex logic in a single MySQL Query
body: <p>I wanted to reduce the programming logic in a code that search hotels by using a single query. </p>
  
  <p><br/>Let say this is the database table. There are several contracts from a single hotel.<br/><br/><a href="https://i.stack.imgur.com/EVSd2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EVSd2.png" alt="enter image description here"></a>  <br/><br/>I wanted to get all the raws that satisfy input number of rooms for max_adults 1(capacity 1) rooms, number of rooms for rooms for max_adults 2(capacity 2) rooms and number of rooms for rooms for max_adults 3(capacity 3) rooms. </p>
  
  <p>eg: <pre>Input : <br/>2 rooms of max_adults=1(capacity 1) <br/>1 rooms of max_adults=2(capacity 2) <br/>3 rooms of max_adults=3(capacity 3)</pre>
  The rows that satisfy all the 3 conditions with the <code>same hotel id</code> must be output.</p>
  
  <p>As in here the output must contain all the raws of <code>hotel 1 and hotel 2</code></p>
  
  <p>Since they are two separate results, an extra column is needed to show a generated result_id (kind of serial number as in <a href="https://stackoverflow.com/questions/11861799/mysql-query-to-select-results-with-auto-increment-as-a-new-column-added-in-the-r">here</a> which must has duplicates acording to this problem). </p>
  
  <p>I'm thinking lots of ways to do this, but nothing works well. Will this be possible to do in a single query?</p>