Merge AND Order multiple MySQL Results in PHP
Posted: Tue Apr 17, 2012 8:32 am
Is it possible to take the result from 4 different MySQL connections (assuming the query and the tables were the same for all 4), and then merge the results, AND sort the result before presenting it (without writing it back into the database, sorting it, and then exporting it again).
$query = "SELECT `Date`, `Result` FROM tablename;";
connect to Database 1 and run query => query1[]
connect to Database 2 and run query => query2[]
connect to Database 3 and run query => query3[]
connect to Database 4 and run query => query4[]
$full = array_merge(query1,query2,query3,query4);
then Print the result into a table, but Ordering it by the `Date` element.
$query = "SELECT `Date`, `Result` FROM tablename;";
connect to Database 1 and run query => query1[]
connect to Database 2 and run query => query2[]
connect to Database 3 and run query => query3[]
connect to Database 4 and run query => query4[]
$full = array_merge(query1,query2,query3,query4);
then Print the result into a table, but Ordering it by the `Date` element.