php - Inner join 2 tables with same column names -
i'm working on displaying achievements minecraft server on website. can't work.
function achievements() { global $id; $sql="select * achievements inner join stats on achievements.type=stats.type inner join stats on achievements.block=stats.block inner join stats on achievements.data=stats.data inner join stats on achievements.value=stats.value player_id = $id"; $result=mysql_query($sql) or die(mysql_error()); $rows=mysql_fetch_array($result); }
will able use $rows['achievements.type'];
, $rows['stats.type'];
column "type" selected table, or there way it?
the column , table names defined plugin use, names can't changed.
the reason why not working because (in own opinion) server little confused on how handle columns names properly. in order work, add alias on every table has same name want join columns, eg
select achievements.*, a.name typename, b.name blockname, c.name dataname, d.name valuename achievements inner join stats on achievements.type = a.type inner join stats b on achievements.block = b.block inner join stats c on achievements.data = c.data inner join stats d on achievements.value = d.value player_id = $id
assuming want get names every specific columns.