Need "select ... as..."?
Posted: Fri Aug 07, 2009 10:45 am
I just spent two hours (I'm a php newbie) trying to get this query to work:
without success.
, even though the query worked perfectly well from the MySQL command line.
Finally, just trying anything I could think of, I tried inserting "as facName":
This seemed to work.
My question is this:
Neither Meloni's PHP, MySQL and Apache nor Welling and Thomson, PHP and MySQL Web Development seem to say anything about such a move being necessary. So
--is this move in fact necessary, given that the query works fine from the mysql command line?
--if so, how would one find this out other than by trial and error?
--or did the query actually run right in PHP but there's a trick to extracting the result that I'm missing?
Thanks.
Code: Select all
$sqlAdvisors = "SELECT tblFaculty.fac_name
FROM tblFaculty
RIGHT JOIN tblStudFac ON tblFaculty.fac_id = tblStudFac.fac_id
WHERE tblStudFac.stud_id = 4";Finally, just trying anything I could think of, I tried inserting "as facName":
Code: Select all
$sqlAdvisors = "SELECT tblFaculty.fac_name AS facName
FROM tblFaculty
RIGHT JOIN tblStudFac ON tblFaculty.fac_id = tblStudFac.fac_id
WHERE tblStudFac.stud_id = 4";My question is this:
Neither Meloni's PHP, MySQL and Apache nor Welling and Thomson, PHP and MySQL Web Development seem to say anything about such a move being necessary. So
--is this move in fact necessary, given that the query works fine from the mysql command line?
--if so, how would one find this out other than by trial and error?
--or did the query actually run right in PHP but there's a trick to extracting the result that I'm missing?
Thanks.