Page 1 of 1

Merge two mysql_query results

Posted: Wed Sep 07, 2011 9:57 am
by davidhopkins
Hello !

In my code i generate two mysql_query results as shown

Code: Select all

       $Result = mysql_query( $Query );
       $SecondResult = mysql_query( $LabQuery );
I need to then merge these into one array to send back as a return

Both mysql queries have the same data in them in terms of database fields, instructionType, priceCode, price

Could someone help me please

Thanks

David

Re: Merge two mysql_query results

Posted: Wed Sep 07, 2011 10:03 am
by Celauran
Could you not use a multidimensional array?

$array['table1']['foo']
$array['table1']['bar']
$array['table2']['foo']
etc.

Re: Merge two mysql_query results

Posted: Wed Sep 07, 2011 10:16 am
by davidhopkins
Im sorry im not sure how i would implement that . .

Re: Merge two mysql_query results

Posted: Wed Sep 07, 2011 10:44 am
by AbraCadaver
Use a UNION query. How it is structured will depend on if you have a WHERE clause, ORDER BY etc... [text]SELECT * FROM table1 UNION SELECT * FROM table2[/text]
http://dev.mysql.com/doc/refman/5.0/en/union.html