Hello,
Okay here is what i have so far (i simplified it down to its essence in order not to complicate things):
foreach(array("tablename1","tablename2","tablename3") as $table)
{
$result = mysql_query("SELECT orderid FROM $table ORDER BY orderid ") or die(mysql_error());
while($tmp = mysql_fetch_assoc($result))
{
$resultarray[$i] = $tmp;
$resultarray[$i]['table'] = $table;
$i++;
}
}
return $resultsarray;
The goal with the above code is to fetch all the orders from the different tables and make one big list out of them. The orderid here is an incremental number that is given out by another table so that all orders (regardless of the table/service) have sequential order numbers.
The problem with the above code is that the resulting orderids are not in order throughout the whole list but only in order as they come out of the tables. ie) 1,2,5,6,3,4
My question is: Can this be done in one mysql query rather than one query for every table? In other words, how do i join multiple tables together when there is no common data point only a common column name?
Thanks in advance,
Emrys