lordzardeck Posted January 17, 2009 Share Posted January 17, 2009 I was just wondering how you would call a field in mysql over two tables with the same name. My select statement is below: SELECT item.author, item.itemid, item.title, item.publisher, item.gradelevelid, item.accessionnum, itemsubject.itemid, itemsubject.subject, item.accessionnum, circulation.datedue, circulation.itemid FROM item LEFT OUTER JOIN itemsubject on itemsubject.itemid=item.itemid LEFT OUTER JOIN circulation on circulation.itemid=item.itemid Link to comment https://forums.phpfreaks.com/topic/141244-solved-call-fields-with-same-name/ Share on other sites More sharing options...
Mark Baker Posted January 17, 2009 Share Posted January 17, 2009 You assign an alias to the column: SELECT item.author, item.itemid, item.title, item.publisher, item.gradelevelid, item.accessionnum, itemsubject.itemid AS itemsubject_itemid, itemsubject.subject, item.accessionnum, circulation.datedue, circulation.itemid AS circulation_itemid FROM item LEFT OUTER JOIN itemsubject ON itemsubject.itemid=item.itemid LEFT OUTER JOIN circulation ON circulation.itemid=item.itemid Then when you use $row = mysql_fetch_assoc() you can reference $row['circulation_itemid'] or $row['itemsubject_itemid'] Link to comment https://forums.phpfreaks.com/topic/141244-solved-call-fields-with-same-name/#findComment-739297 Share on other sites More sharing options...
lordzardeck Posted January 17, 2009 Author Share Posted January 17, 2009 Thanks, I should have realized that. I feel so stupid. Link to comment https://forums.phpfreaks.com/topic/141244-solved-call-fields-with-same-name/#findComment-739301 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.