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