当我使用node.js中的pg向数据库发送LEFT JOIN查询时,我有一个名为“ExternalCategories”的表我得到了难以理解的结果
'SELECT * FROM "ExternalCategories" a Left JOIN "externalcat" b ON a."parentCategoryId"=b.id'
我明白了:
{
"id": 34,
"name": "Ordinateurs et Resea",
"img": null,
"views": 0,
"parentCategoryId": null
},
{
"id": null,
"name": null,
"img": null,
"views": null,
"parentCategoryId": null
},
{
"id": 1,
"name": "Vêtements",
"img": null,
"views": 0,
"parentCategoryId": null
},
{
"id": 34,
"name": "Ordinateurs et Resea",
"img": null,
"views": 0,
"parentCategoryId": null
},
但是当我在Datagrip或pgAdmin4中运行相同的查询时,我得到了正确的数据 Results in datagrip
答案 0 :(得分:0)
考虑区分返回的列名称别名
'SELECT a.id AS a1, a.name AS c2... FROM ExternalCategories a ....'