I am running a SELECT query and it has a.id and c.id like so:
$sql = "
(SELECT
a.id,
a.Title,
a.Category,
c.id,
c.cateName FROM ads_list
AS a LEFT JOIN ads_cate
AS c ON c.id=a.Category WHERE a.Category = $CatID)"; // $CatID is defined earlier in the script but is not pertinent to this problem.
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) { echo $row['id'] // equals c.id }
But $row[‘id’] is the last id called in the query and evaluates to c.id. I need to get a.id in my while loop.
My question is how do I get the value of a.id and c.id in my while() loop uniquely?
Give an alias to the
c.idcolumn.Try this: