title: MySql get data from multiple tables results from a select
body: <p>I have a table "move" like this</p>
  
  <pre><code>----------------------------------
  | id | ... | ... |  tab  | idTab |
  ----------------------------------
  | 1  | ... | ... | bike  |  14   |
  | 2  | ... | ... | car   |  57   |
  | 3  | ... | ... | car   |  23   |
  | 4  | ... | ... | bike  |  43   |
  | 5  | ... | ... | boat  |  20   |
  | .. | ... | ... | ...   | ....  |
  ----------------------------------
  </code></pre>
  
  <p>tab "bike"</p>
  
  <pre><code>---------------------------------
  | id | code | name  | matr | ... |
  ---------------------------------
  | .. | ...  | ....  | .... | ... |
  | 14 | AAA  | MARIO | 111  | ... |
  | .. | ...  | ....  | .... | ... |
  | 43 | A1C  | JOHN  | EEE  | ... |
  | .. | ...  | ....  | .... | ... |
  ---------------------------------
  </code></pre>
  
  <p>tab "car"</p>
  
  <pre><code>---------------------------------
  | id | code | name  | matr | ... |
  ---------------------------------
  | .. | ...  | ....  | .... | ... |
  | 23 | 123  | JACK  | WER  | ... |
  | .. | ...  | ....  | .... | ... |
  | 57 | 2A2  | FRANK | MSS  | ... |
  | .. | ...  | ....  | .... | ... |
  ---------------------------------
  </code></pre>
  
  <p>tab "boat"</p>
  
  <pre><code>---------------------------------
  | id | code | name  | matr | ... |
  ---------------------------------
  | .. | ...  | ....  | .... | ... |
  | 20 | UJN  | PETER | WSX  | ... |
  | .. | ...  | ....  | .... | ... |
  ---------------------------------
  </code></pre>
  
  <p>I would like to have in a single query all datas of "move" and the datas of each tables present in "move" with specific idTab.</p>
  
  <p>The result will be like this</p>
  
  <pre><code>--------------------------------------------------------------
  | id | ... | ... |  tab  | idTab | code | name  | matr | ... |
  --------------------------------------------------------------
  | 1  | ... | ... | bike  |  14   | AAA  | MARIO | 111  | ... |
  | 2  | ... | ... | car   |  57   | 2A2  | FRANK | MSS  | ... |
  | 3  | ... | ... | car   |  23   | 123  | JACK  | WER  | ... |
  | 4  | ... | ... | bike  |  43   | A1C  | JOHN  | EEE  | ... |
  | 5  | ... | ... | boat  |  20   | UJN  | PETER | WSX  | ... |
  | .. | ... | ... | ...   | ....  | ...  | ....  | .... | ... |
  --------------------------------------------------------------
  </code></pre>
  
  <p>I don't know in effect if I have or not a specific table in move. 
  I can make a query like this </p>
  
  <pre><code>SELECT * FROM move WHERE id&gt;0 
  </code></pre>
  
  <p>and then a foreach with </p>
  
  <pre><code>SELECT * FROM move["tab"] WHERE id=move["idTab"]
  </code></pre>
  
  <p>but is very hard work because table move is very long...</p>
  
  <p>I try with this but (obviously) don't work...</p>
  
  <pre><code>SELECT M.*, T.* FROM move as M, M.tab as T WHERE M.id&gt;0 AND M.idTab=T.id 
  </code></pre>