I have a query that joins two tables that share a field name. I want to grab the field name of one, not the other after converting the results into an array using fetch_array.
I feel like I have accomplished this with a simple alias numerous times but this time it is not working. Can anyone please help me find the error. Many thanks.
Code is:
$sql = "SELECT i.*,ic.* FROM `items` i
LEFT JOIN `itemcat` ic ON i.id= ic.itemid
WHERE (shortdescript LIKE '%%' OR longdescript LIKE '%%')
AND ic.catid='23' limit 0,20 ";
$res = mysql_query($sql) or die(mysql_error()); //query executes no problem
while($row = mysql_fetch_array($res)) {
$id = $row['i.id'];//I do not understand why this is not getting anything.
$id2 = $row['id'];//returns id but from wrong table.
echo $id; //returns blank.
echo $id2; //returns id of itemcat table when I want id of items table.
}