Jump to content

INNER JOIN


watagal

Recommended Posts

Greetings-When I do an INNER JOIN on 2 tables with the "id" field or column existing in both tables - I get 2 IDs in the fetched record set. How do I distinguish between the 2 while looping thru

while($record = mysql_fetch_array($result)) {	echo $record['tableA.id'];	echo $record['tableB.id'];}

I know the above does not work, what is the correct syntax?TiA, Gal

Link to comment
Share on other sites

print_r($record) and see what it contains.
Ok, it looks like there is only one "id" which is overwritten by the 2nd table's value (9). How do I gain access to the 1st table's "id"? Do I need to rename all my pkeys to a unique name or is there a better way? Thanks, Galprint_r($record) =
	[0] => 5	[id] => 9	[1] => 1	[countryId] => 1	[2] => 3	[areaCodeId] => 3	[3] => 555-5555	[phoneNumber] => 555-5555	[4] => 1	[origMemberId] => 1	[5] => 1	[isActive] => 1	[6] => 2008-06-23 17:13:23	[date] => 2008-06-23 17:13:23	[7] => Family	[share] => Family	[8] => 3	[9] => 555	[areaCode] => 555	[10] => 9	[cityId] => 9	[11] => 9	[12] => 4	[stateId] => 4	[13] => San Jose	[name] => San Jose

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...