SQL联合查询,相同字段名怎么获取结果?
$sql = mysql_query("SELECT * FROM tableA JOIN tableB ON tableA.ID = tableB.parent")
$row = mysql_fetch_array($sql);
两个表都有字段ID 用echo $row['tableA.id ']; $row['tableB.id '] 无法显示
把*换成要查询的字段可以显示,可是字段多不想每次都写。MYSQL就是这样的,相同的列,可以这样把
SELECT *, tableA.id AS tableAid, tableB.id AS tableBid FROM ....