title: Insert the existing value and sort it from another table
body: <p>Insert the existing value and sort it from another table</p>
  
  <p>I'm trying to call data from table A and but table A is sorted from table B.</p>
  
  <p>Detail: Table A stores "ID" and table B stores numbers, I want to sort table A based on the numbers in table B.</p>
  
  <p>I tried the code below but it didn't work</p>
  
  <pre><code>$result = $db-&gt;Query("INSERT INTO `session`(`id`)VALUES('".$id['tableA']."' ON SELECT * FROM `tableB` WHERE `number`&lt;'500' )") ;
  </code></pre>
  
  <p>After I run the code does not save to the database.</p>
  
  <p>I hope the experts can solve my problem. thank you</p>