我有两个表,两个表具有相同的列名,称为ID(存储记录ID)。我在这2个表上使用内部联接,并采用2个表的id列。我在angularjs http.get
rest API中使用此选择查询。当其余的API抛出包含2个同名ID列的结果表时,我将其存储在scope变量中。
问题是我如何使用一个特定表的ID。
考虑到查询是,
select t1.id,t2.id
from table1 AS t1
INNER JOIN table2 AS t2 ON t2.product=t1.product_id
我将其余API的结果存储在作用域变量中, $scope.details=response.data.platform.record;
我在控制器的警报框中使用了以下语法,但不起作用$scope.details.id, $scope.details.t1.id
。
使用列别名name可以解决您的问题:
SELECT t1.id AS T1Id,
t2.id AS T2Id
FROM table1 AS t1
INNER JOIN table2 AS t2 ON t2.product = t1.product_id
在您的控制器中,您可以用作:
$scope.details.T1Id
$scope.details.T2Id
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句