Referencing the same column from table aliases
Posted on 2004-03-31
These tables don't make a lot of sense, but they are for illustrative purposes only:
ID | Result
Name | FactID1 | FactID2
Jane 1 2
Bob 1 3
$query = "select Name, Res1.Result, Res2.Result from RefTable, FactTable Res1, FactTable Res2
where RefTable.Fact1ID = Res1.ID and RefTable.Fact2ID = Res2.ID"
$res = mssql_query($query);
$n = mssql_num_rows($res);
$a = mssql_fetch_array($res);
$name = $a['Name'];
// MY QUESTION: how do I reference Res1.Result and Res2.Result here? $a['Result'] won't work,
// it's ambigous. Also fully qualified $a['Res1.Result'] does not work. What is the correct syntax?