Home >Backend Development >PHP Tutorial > SQL联合查询,相同字段名如何获取结果

SQL联合查询,相同字段名如何获取结果

WBOY
WBOYOriginal
2016-06-13 12:29:481129browse

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 ....

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn