选择特定于表格的列

时间:2016-05-21 08:03:23

标签: sqlite

我在多个不同的表中有相同名称的列。我使用JavaScript发送包含字段的对象,Node.js包创建一个带有名称的数组,因此如果两列具有相同的名称,则最后一列的值似乎放在数组中。

我有这个查询

SELECT * 
FROM FACTURATION AS F 
LEFT JOIN ENREGISTREMENT AS E ON F.Enregistrement=E.Numero 
LEFT JOIN RESTITUTION AS R ON F.Restitution=R.Numero 
LEFT JOIN RESERVATION AS X ON F.Numero=X.Facturation 
LEFT JOIN CLIENT AS C ON X.Numero_Client=C.Numero

返回我的值。知道Select *不是一个好习惯,我将其改为

SELECT Nom, Caution, Kilometrage 
FROM FACTURATION AS F 
LEFT JOIN ENREGISTREMENT AS E ON F.Enregistrement=E.Numero 
LEFT JOIN RESTITUTION AS R ON F.Restitution=R.Numero 
LEFT JOIN RESERVATION AS X ON F.Numero=X.Facturation 
LEFT JOIN CLIENT AS C ON X.Numero_Client=C.Numero

它也可以。但后来我需要将两列与不同的表区分开来。我试过了

SELECT CLIENT.Nom, ENREGISTREMENT.Caution, ENREGISTREMENT.Kilometrage 
FROM FACTURATION AS F 
LEFT JOIN ENREGISTREMENT AS E ON F.Enregistrement=E.Numero 
LEFT JOIN RESTITUTION AS R ON F.Restitution=R.Numero 
LEFT JOIN RESERVATION AS X ON F.Numero=X.Facturation 
LEFT JOIN CLIENT AS C ON X.Numero_Client=C.Numero

它什么也没有回报。即使我只选择CLIENT.Nom,但在选择Nom时工作正常也无效。 我使用sqlite3

中的Node Package Manager

1 个答案:

答案 0 :(得分:1)

您可以使用列名的别名来代替表名。

$scope.foo