I want to execute two select queries in one go, but the data isn’t related to each other so a LEFT JOIn etc. will not do.. because then I end up with data I can’t use.
What I got so far is;
$sql .= "SELECT *,
servertypes.id as servertypeID,
servertypes.name as servertypeName
FROM servertypes";
$sql .= " JOIN".
" (SELECT *,
periods.id as periodID,
periods.daysForSorting as periodNumber,
periods.text as periodsText
FROM periods
) AS periods";
$res = mysql_query($sql);
if(!$res) die("database_error_cant_select_data : ".$sql." : ".mysql_error());
But now how do I access servertypes and periods separately? I think I have to stop using JOIN altogether but I wouldn’t know…
To illustrate what I mean, it’s something like:
while ($row = mysql_fetch_assoc($res["servertypes"]))
{
print_r($row);
echo"<br/><br/>";
}
while ($row = mysql_fetch_assoc($res["periods"]))
{
print_r($row);
echo"<br/><br/>";
}
Is this possible using only one query?
Normally, you could do something like that IF both query return the same column number
But here, nothing is related. So to answer your question : no you cannot do what you want.