以前从来没有遇到过这个......
SELECT ".TBL_USERS.".username,
".TBL_USERS.".id, <-----------|
".TBL_COMMENTS.".creator, |
".TBL_COMMENTS.".comment, |- same column name
".TBL_COMMENTS.".date, |
".TBL_COMMENTS.".id <---------|
如您所见,我正在选择两个 id 列...当我将它们放入 PHP 中时:
$userid = $row['id'];
我怎样才能知道哪个是哪个?
最佳答案
您需要使用列别名,使用 AS
关键字:
示例:
(id) AS id1.........(id) AS id2
现在从你的查询结果中,你可以这样得到它们:
$userid1 = $row['id1'];
$userid2 = $row['id2'];
更多信息:
关于php - 连接问题和 2 个确切的列名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3611797/