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

WBOY
Release: 2016-06-13 12:29:48
Original
1108 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template