我使用联接查询从具有相同字段名的两个表中检索值。如何获取这两个字段的值?
mysql_query("SELECT table1.Name, table2.Name
FROM table1
INNER JOIN table2
ON table1.Id=table2.userid
ORDER BY table1.Id DECS LIMIT 5") 在上面的查询中,我需要来自table1.Name和table2.Name的值。
发布于 2013-04-04 18:03:21
把alias给我
SELECT table1.Name as table1Name, table2.Name as table2Name
FROM table1
INNER JOIN table2
ON table1.Id=table2.userid
ORDER BY table1.Id DECS LIMIT 5注释: 。它们不再由and are officially deprecated维护。看到了吗?相反,学习,并使用PDO或MySQLi - this article将帮助您决定使用哪种方法。如果你选择PDO,here is a good tutorial。
发布于 2013-04-04 18:03:36
使用别名:
mysql_query("SELECT table1.Name as table1_name, table2.Name as table2_name
FROM table1
INNER JOIN table2
ON table1.Id=table2.userid
ORDER BY table1.Id DECS LIMIT 5") https://stackoverflow.com/questions/15808133
复制相似问题