groupbrand Posted July 4, 2012 Share Posted July 4, 2012 I have an issue when trying to retrieve results from an inner join query where the tables queried have column names. Basically if I inner join table1 with table2 and they both contain an id field, the query results return a table1.id and table2.id (along with any other column data requested). When I run through the results using mysql_fetch_assoc I can grab any unique column data but using $row['colname'] but I cannot get data from columns that have the same name e.g. $row['table1.id'] - can anyone point me in the right direction? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
trq Posted July 4, 2012 Share Posted July 4, 2012 Use an alias. eg; SELECT tbl1.col AS foo, tbl2.col AS bar Quote Link to comment Share on other sites More sharing options...
Barand Posted July 6, 2012 Share Posted July 6, 2012 But if you are doing an INNER JOIN on the id columns and they both have the same value, why would you need to select both of them? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.